MaterialInputField question

0 votes
asked Feb 2, 2017 in Help by raydekk (530 points)
Hey guys,

I'm trying to modify leftContentActiveColor and rightContentActiveColor at runtime, in a script. It works, but the change isn't visible unless i trigger some GUI update from the editor. Like modifying the color manually in the editor - this refreshes all the modifications I made with the script.

Any idea what function I need to call after I change the color?

Thanks!

1 Answer

+1 vote
answered Feb 2, 2017 by admin (31,720 points)
selected Feb 3, 2017 by raydekk
 
Best answer
Hey :)

We must make some work on these properties so they can be used at runtime too you're right...
But for now, you should be using leftContentGraphic.color instead of leftContentActiveColor :)

~ Yohan
commented Feb 3, 2017 by raydekk (530 points)
Thanks, I'm trying to make a dark mode version of the UI, so I need to set backgrounds and certain buttons to a darker version at runtime.

Will wait for a runtime patch :)
commented Feb 3, 2017 by admin (31,720 points)
:)

Well, you better use the "trick" I gave because a runtime patch for this is absolutely not on top of priorities :/

~ Yohan
commented Feb 3, 2017 by raydekk (530 points)
foreach (MaterialInputField option4 in darkModeMUI) {
	option4.leftContentGraphic.color = new Color (1f, 1f, 1f, 1f);
	option4.rightContentGraphic.color = new Color (1f, 1f, 1f, 1f);
	option4.hintTextObject.color = new Color (1f, 1f, 1f, 1f);
}

I did that, and it works if I add the function to a switch (Toggle) for example. Each time I click the toggle - the colors are updating.

But when I run the same function at startup, it gets executed and everything is updated, except all the items in my MaterialInputField list.
Really weird.

 

commented Feb 3, 2017 by raydekk (530 points)
But I did fix it with a coroutine that waits 2 seconds and re-runs the function.
Welcome to MaterialUI support! Ask us anything :)
...