Hi everyone.
I'm starting to get problems when using Unity UI as our project scales up. I guess I'm using it the wrong way, so if you have a better solution I'd be glad to know.
I'm trying to make a Splash screen. It's always the same background and 2 changing texts : the title & a subtitle.
We have it displayed 3 times on 2 scenes :
- Scene 1 : [1st splash] ** do something ** [2nd splash]
- Scene 2 : [3rd splash]
I created one prefab for the 3 splashs, so they share the same ID.
I've tested 2 solutions, each one fails short on a different point :
1°/ After creating the prefab, I created 3 menus in the Menu/Editor with differents texts. Source is set to -> Unity UI Prefab.
It works well, but the problem with this solution is that it instantiates every splash screen in every scene (splash 1, 2 and 3 in both scenes). It means that if the game has 50 splash screens (one or 2 for each level), I'll always have 49 useless duplicates in memory. Sounds bad...
2°/ After creating the prefab, I instantiated it in each of the 2 scenes. Then, I created 3 menus in the Menu/Editor with differents texts. Source is set to -> Unity UI in Scene.
In that case, only the very first menu of scene 1 works. It's due to ID confusions.
So, that's my problem, I don't know what to do to get only ONE instance of the splash screen in my scene and get it to work by turning on Menus. Anyone has a better solution ?
Comments
2) Same here - all ID numbers need to be unique, otherwise AC won't be able to tell them apart. If you find a duplicate ID, then reset the Constant ID component to generate a new one. AC will automatically prevent duplicates when working with objects in the same scene - so if you ever want to duplicate a UI, do so in the scene and make a new prefab from it - rather than duplicating the prefab file itself.
2) I wasn't suggesting that - just trying to help with the problem related to 3, not 100. Have you thought about using tokens? That way, you can just have one UI and change the label text dynamically:
Create a Global Variable of type "Pop Up", and enter in each of the texts that the splash screen can have. You can then display that Variable in your Label (see this tutorial), and change it's value (using the Variable: Set Action) to change the UI text.
One other option is to use one Menu/UI, but three separate Labels inside it that get shown/hidden as appropriate. Best to temporarily switch back to Adventure Creator as the Menu's source while you set up the logic, and then switch back to Unity UI once it's set up correctly. You can use the Menu: Change state Action to show/hide individiual elements, or use Object: Animate if you prefer to control the visibility with animation clips.
That said, the ability to translate String and PopUp variables would be a useful feature - I'll look into it in a future update.