Sunday, 14 September 2014

Unity 4.6 BETA - Adding new GUI features and what it means for Salvation!

I have finally managed to find some time to sit down for a few minutes to check out the new Unity beta stuff I been hearing about. Reading/watching the changes that'll be coming with Unity 4.6 specifically the new GUI stuff is getting me all fired up in different ways.

Part of me let out a giant exited SQEEE sound while the other part was experiencing a cold sinking feeling that I'd have to redo all of my GUI stuff I spent so long on. If I should choose to upgrade, that is. And I am pretty sure I will be, after seeing what I've seen thus far. Granted I've only had 30-40 mins to check things out. First impression is really good.

After looking at my game framework thus far, playing my demo level a few times last night. It dawned on me that the GUI still feels clunky. It functions fine, but it feels like it could be done better. I click on a panel and it opens up, and I know that each element that is now visible is a separate thing entirely. Tied together by a parent gameObject. But making sure all these elements act together in a synchronised way is tricky. And even though it looks fine now I know that adding more UI features is going to be a huge head ache.

Each element is a separate UI object I have to worry about!
For example the way my GUI is structured, I have to worry about each GUI element separately. For example scaling them based on aspect ratio, requires me to run the same script on each and every GUI element that I use. The new Unity UI will implement a new type of transform, called a Rect Transform. This thing is awesome and you can use it, with Anchors to have all UI elements scale themselves based on the parent element, which could be a canvas. Which brings me to the next feature I'm happy about. 

The canvas is a parent element that all UI elements belong too or need to belong too. If no canvas exists for an element when it is created then one will be made. This is awesome since I do this manually currently. I have an empty object called MasterPanel and this panel has all the GUI panels as children, which in turn have all their children. However doing this manually still takes time and makes things look and feel clunky and fiddly. Just because a gameobject is a parent doesn't mean I don't have to worry about each childs separate settings. For each child, which there are many of! Giant head ache. So I'm stoked about the Canvas. At a glance it seems like they'll allow me to change children elements in a more unanimous fashion. I'm hoping this is the case.

Panels panels panels panels panels ALL DAY panels
The workspace UI elements feature, that canvases will allow for, is amazing good news for me. The latest UI feature I added a few nights ago were little message pop ups that appeared for example whenever a ship offloaded new refugees to the station. I wanted this GUIText (string) message to appear where the ship docked. And as the ship is a moving object in world space (3D space), getting the right transform was a little bit tricky. However, what I am finding very difficult to near impossible at the moment is how to convert the GUIText transform to that of the gameobjects transform. For some reason even though they are identical, they appear different in world space. Making things look buggy and miserable. 

Ship Transform

GUIText with same transform
This new feature will allow me to add my code to a worldspace UI element easy and things will work and look right. As the worldspace UI element is not tied to local space it will make things so much easier. And I will not have to be comparing floating points and doing a ton of number tweaking to get transforms looking right.

So is this a huge step back for Salvation? Not huge but some tweaking will be required. As I'm still working on the framework I feel that if I were to make a change like this now would be the best time to do it. As things are still at their most basic level. A little work now will save a lot of work in the future.

Since Unity 4.6 is still in beta, I can't just make the jump right now and I'm not really sure when it's being released. What this most likely means is that my UI stuff will take a backseat for now. I'll instead focus on the other game features, as there's a lot of stats and numbers flying about. I'll also be checking out 4.6 in more detail and learning the new GUI features on offer so I acn hit the ground running.

I am also going to be removing my terrible programmer art and going to add in 3D models. Basic ones for now so that I can mess around with shaders.

There's a lot to do so I am not to nervous about leave the GUI stuff for now. Especially seeing as how fixing the GUI up has taken up all my time thus far.

Unfortunately I need to stop research for now, as I am actually on my way out the door again, this week end has been busy and not in terms of my games development. Additionally I finish my University enrolment next week, so things might be getting busy. But fear not as I am super keen to crack on with things!

Have a great Sunday everyone :)

No comments:

Post a Comment