2D Toolkit Forum
2D Toolkit => Support => Topic started by: Thyran on September 25, 2014, 08:04:42 pm
-
Hey,
Is there an easy approach to fading complex UI's in/out? Currently, on Start(), I'm building a List of all Text Meshes, tk2dSprites, tk2dSlicedSprites, etc for all elements in the UI. Then, when the menu needs to fade in/out, I'm cycling through them all to run a HOTween fade. It gets the job done but doesn't seem to be very efficient to accomplish this task. Just wondering if there was a better way to go about this.
Thanks!
-
You could have one material assigned to all of those (you'll need a material with a color parameter) and fade that instead? That could be considerably easier, but would add complexity in managing these materials.
ps. You dont need to make a list of tk2dSprites, tk2dSlicedSprites, etc, just a list of tk2dBaseSprites will do (assuming you're using GetComponentsInChildren). You can also do this in an editor script to avoid that overhead there.
-
Great thanks! Since I'm using this for a lot of the UI components, I'd imagine many of them will use the same material, and I wouldn't really want to create a new material for each screen of a UI, so I'll probably go the second route.
When you say doing that in the editor script, would that just save the overhead in the loading of a scene? I'm populating all these lists in the Start() function, so after those lists are populated, while the game is actually running it really wouldn't matter whether I loaded them in the editor or at runtime, right?
Thanks!
-
Yeah that should be fine, in an editor script would avoid even doing it in Start. Its a bit of work to figure out how to do it, but once you do you can use that for all sorts of useful things. Highly recommended!
-
Great thanks! Will do!