Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: Al.Kapole on January 21, 2014, 06:52:28 AM
-
Hi!
I have created a widget that holds 2 panels inside it. Each panel has its own sprites and buttons!
What I want to do is, use these panels in many cases and change only the colors of sprites and buttons.
So I created a script that changes the color of all buttons and sprites. Now the problem is that when I change the colors of buttons something goes wrong and it does not work properly!
I change the color of a button like so...
infoBackBtn.defaultColor = blue1;
infoBackBtn.hover = blue2;
infoBackBtn.pressed = blue3;
infoBackBtn.UpdateColor(true,true);
blue1,blu2,blu3 are colors of mine! ex. private Color blue1 = new Color(0.3f,0.3f,0.8f,1f);
While the game running Iwatch a button at the inspector and I see that hover color and onPressed color change to what I told it to, though the defaultColor remains white, also the tweens are not working when I hover the button or when I press the button, It's color remains white.
While the game starts the main widget is disabled(from editor). when I click an object, it enables the widget and shows the first panel.
First panel's buttons work ok. The problem is at the other panel (which comes after I click a button from the first panel).
Also I tested having the main widget enabled(from editor) and showing the panel (that has the problem) before the game starts, and when I click to change the color then it works ok. But I don't want to have the main widget enabled from the beggining!
Thank you!
-
A widget that holds 2 panels inside of it, and each panel has a set of sprites and buttons?
That seems a bit odd. Why have panels in there? The tabbed window example doesn't use any extra panels. Adding panels there just complicates things and increases draw calls for no good reason.
Other than that, I don't see anything wrong with the code you posted, but I'd suggest checking the order of execution. UpdateColor doesn't need to be called if the button is disabled. Also, don't forget that setting the default color doesn't change the current color of the button. Only the default one.
To change the current color of the button, change the color of the widget referenced by the button.