This engine is frustrating.

Seriously, this is frustrating and very annoying me off since few weeks.

It’s hard to find tutorials for Unity 5 that talks about the UI system and how implement it well in a game. All I can find is generic 2D / Mobile game tutorial that have nearly nothing in it. It’s been months Unity 5 is out and it’s nearly impossible to find concrete and complete resources about it.
I tried to reject the fact Unity was bad but it seems to be right, or at least a little.

My project is not complex, it’s just yet-another-3D-shooter online game, I already master the network library with ease (got it in trial 1 month ago, 2 months left, I still have not been able to use it the way I want in Unity !), but Unity makes everything harder for everything I want to do.
I’m a C++ coder, that might explains why I can’t get in the Unity-hell of a mess-scripting system as I’m familiar with the OOP.

So, it’s pretty simple:
Since it’s an online game, I obviously need a Login screen, right ? Right, and like every online game out there, you have a character or anything to control, so when you login, you have to create or maybe even select it for some games, right ? Ok we got a start here. Now, how to code it ?

With all the tutorials I saw until now, I would have made the most unoptimized game ever just with this simple example, because everything is played with hide/show, just imagine on a very detailed UI !
So with my example it could be like this:

[×] Scene: Login - Everything that happens before entering the game world
[-] Login
[-] Channel Selection - for a MMO game for example
[-] Select Character
[-] Create Character - only if we need to
[×] Scene: Loading - Entering the world, unfortunatly games still have loading times …
[-] Loading
[×] Scene: Game - The game world itself
[-] Explore - this is where you actually move freely in the world

So the reason I did it like that is that you won’t change scene everytime you have something different to do, you could have for example some data to keep while in the Login scene (but not once in the game), and it would add a degree of complexity of having a scene for each screen, as you would have to manage the lifetime of your data by yourself.

I find it pretty clear like that, but the reality is way more complex than that, because now, how will Unity handle it ?

While in the Login scene (let’s say it’s a full 2D scene), it’s pretty simple, it’s just UI switch, then once we need to enter in the game world, we send the user to the Loading screen to process data (like receiving your inventory) before actually be able to move freely in the world along with other players. I don’t think I can be more precise than that

But then comes another problem, the in-game HUD, how to display a 2D UI in a 3D world without the scene in Unity Editor being a complete mess.

What about windows or message boxes, those can’t be put in a specific scene, as they could be used in anywhere in the game.

This is where, I think, there is a problem with the Unity UI, where is the correct place of the UI ? As I saw with most of the other games, they usually separate the UI into their own files, in Unity it would give an additive scene per UI. Take my exemple back, and you will see it will be complicated to integrate it, and I’m not even talking about the cost in performance.

Anyone experienced this frustration already or am I the first ? And it would be interesting on having a debate about the Unity UI implementation in it’s current state (and it’s missing controls like List …)

Build it in a scene , save it to a prefab and reuse it in any scene you need it.

Separating complex UI into a separate scene worked fine in some projects. (with NGUI and Unity UI).

You have to find your way with unity to build a good usable structure to handle your UI.

Try multiple canvas elements, treated as game objects, animated or hide/show…at will…2 draw calls max.
GUI was frustrating!!

5 windows: Live, Mission, game over, message, settings…under 1 canvas!

Hard to really understand what you are asking, most of the post seems to be a long rant about being frustrated that you’re not comfortable in Unity yet.

Thanks for your answers,

My problem is simple: I want to be able to switch UI being displayed on the screen, and I want to be able to display normal windows on top of it (sometimes multiple)
Using pre-fabs might sound like a good solution but what happens when I have to edit it ?

I watched the Modern GUI Development tutorial series but it loads everything on the same scene, and it feels a bit weird, especially considering the size of my “screens” are wide resolution 1366x768 and more, and what happens when I have more than 10 windows ? The scene loading will take a lot of time

Yes I know, it’s because I find a lack of documentation on the subject of the UI, and ESPECIALLY a lack of tutorials in Unity 5 in general

Anyone please ?
I really need help on this, it’s been months

What exactly is not working? Are the windows supposed to be modal? What exactly is the issue with editing the prefabs?

What is the problem with the loading time for more than 10 windows? What exactly do you have in those windows that has such a huge impact on the loading times? There is also the possibility to not load all of them at the beginning, but asynchronously e.g. by using asset bundles. But I don’t know whether this is possible in your example.

When my game start, the first scene is the Game Login scene.
The first screen in that scene is the login screen, then once we click a button, the GUI changes to another one BUT it stay on the same scene (so I can keep audio, background and whatsoever I need to keep while logging in the game), then it happens again and again (character creation, world selection etc) until I finally change to another “level” which would be the Game Loading

Problem is, where do I put those UI, in the login scene, or in separated scenes for each ? And how do I do that switch ?
Then my second problem is, there are windows I will need from multiple scenes (like popups), those can be equivalent of MessageBoxes but it can also be windows like a Skill Window (even if it’s unlikely to be called in a Login scene, it’s just to give an example), again, where do I put them ? How can I use them ?

And for the prefabs, the problem is that I want to be able to edit the windows pretty fast, if I use prefab, I’ll have to make a new scene in the editor, import the prefab to edit it and then remake the prefab, I’m wondering if it would not break the existing prefabs.

Each of those can be inside of its own main game object. E.g. you can create a Login game object that contains the UI for the login. It may or may not have its own canvas. If you want to show the login, just activate this game object and deactivate the game objects containing the other UIs that are not relevant right now.

It is not necessary to create a new scene in order to edit the prefab. You can drag the prefab into your UI in order to make modifications, then you apply the changes within that prefab and delete it. That’s all you need to do.

But how to do the transition from one GUI to another within the same scene? It seems complicated to implement. Unity should have it integrated in it’s UI system … It doesn’t feel right to have everything on the same scene …

As a starting point, you can simply activate and deactivate the things you need. It is not yet a smooth transition, but definitely a starting point. Once this is working, you may consider to do something that is more complicated. You can fade them in and out by modifying the alpha or you can make those fly in and out of the screen.
It is possible to code that behavior, maybe with some tween script package from the Asset Store or to use animation clips.
I agree that it can feel weird to have all those windows in the same scene, but you can try some thing out about what kind of arrangement is most practical for you. You may e.g. try to place them next to each other and give them the correct positions as they are needed or whatever else you like.

1 Like

Alright I tried to do with your idea and I did this: http://pastebin.com/i2XpZxNc
I attach it to the canvas and it moves every GameObject I added to the list to the canvas position

I would like to improve it but I have no idea how yet, and I’m sure this could be done in a better way :s

There are a lot of different approaches. You may e.g. have an interface which is implemented by all the components you want to control. In the canvas or the UI camera, you may have a script that controls all those components. With this setup, you could e.g. use GetComponentsInChildren () to get all the components you want to control. This controller knows now all the relevant components and you can make it responsible for the activation and deactivation. It is also possible to let it animate of fade those components individually.
As mentioned, this is just an example and there are many different approaches. In my opinion the advantage of the Unity UI is that it is now consistent with the rest of Unity.