Author Topic: Change widgets color at runtime  (Read 1357 times)

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Change widgets color at runtime
« on: March 17, 2014, 01:05:42 PM »
There's a way to change the color of several widgets at runtime?
I'm using white/light-grey assets so I add color using the widget property. But I'll like to change all the assets colors at the same time.

Example:
Change all widgets with this color to the next one:

Base)           To)
R: 255          R: 150
G: 255          G: 200
B: 150          B: 150
A: 255          A: 255

Any help will be appreciated!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Change widgets color at runtime
« Reply #1 on: March 18, 2014, 02:59:04 PM »
GetComponentsInChildren<UIWidget>() and iterate through them changing the color to what you want.

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Re: Change widgets color at runtime
« Reply #2 on: March 19, 2014, 08:50:56 AM »
yeah, but I was thinking to change the color itself, like Black is not Black anymore it it's Yellow.

A colleague recommend me to use Tag to all the assets I want to change and then look for all of them and change ir looking for that specific tag. Apparently that's the approach.