Hello Guest

Author Topic: Fading UI's In/Out  (Read 5234 times)

Thyran

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Fading UI's In/Out
« 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!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Fading UI's In/Out
« Reply #1 on: September 26, 2014, 09:35:31 pm »
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.

Thyran

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Fading UI's In/Out
« Reply #2 on: September 27, 2014, 01:36:29 pm »
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!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Fading UI's In/Out
« Reply #3 on: September 27, 2014, 07:37:20 pm »
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!

Thyran

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Fading UI's In/Out
« Reply #4 on: September 30, 2014, 03:12:14 pm »
Great thanks! Will do!