Welcome,
Guest
. Please
login
or
register
.
October 03, 2023, 01:25:44 PM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
UIButton.UpdateColor();
« previous
next »
Print
Pages: [
1
]
Author
Topic: UIButton.UpdateColor(); (Read 2838 times)
mjost
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 4
UIButton.UpdateColor();
«
on:
March 10, 2014, 08:49:46 AM »
Hi everyone,
I just updated to the latest version (3.5.3). UIButton.UpdateColor() has been removed, so I had to uncomment it everywhere. What function is supposed to replace this functionality? Can't find anything in UIButton...
Thanks
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: UIButton.UpdateColor();
«
Reply #1 on:
March 10, 2014, 07:38:27 PM »
UIButtonColor has a "SetState" function, which is virtual, and gets overwritten by UIButton. This function gets called when the state of the button changes -- such as "hover" or "pressed".
Logged
mjost
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 4
Re: UIButton.UpdateColor();
«
Reply #2 on:
March 11, 2014, 04:08:58 AM »
I can see that the color gets updated when I hover over it, but I programatically change the color on startup. Is there a way to trigger the "setState" function programatically? UpdateColor() worked perfectly for my needs...
Logged
mjost
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 4
Re: UIButton.UpdateColor();
«
Reply #3 on:
March 11, 2014, 04:56:30 AM »
Also if I disable a button programmatically by setting "enabled = false", the color doesn't change to the disabled one. I used to also call UpdateColor() after each modification of "enabled"
Logged
mishaps
Jr. Member
Thank You
-Given: 0
-Receive: 0
Posts: 65
Re: UIButton.UpdateColor();
«
Reply #4 on:
March 11, 2014, 05:30:35 AM »
I have the same problem. I programatically changed the colour of a few buttons using this and my code is now broken in the latest version. What should I do in its place since its been removed?
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: UIButton.UpdateColor();
«
Reply #5 on:
March 11, 2014, 04:11:14 PM »
UIButton has the "isEnabled" flag you should be setting instead of 'enable'.
SetState effectively plays the same role as UpdateColor, with the added benefit of you explicitly specifying which state to assume. Note that the function won't do anything if you are setting the same state repeatedly due to a check on line 263 of UIButtonColor.
If you are trying to change the color of the sprite immediately, do just that:
button
.
tweenTarget
.
GetComponent
<
UIWidget
>
(
)
.
color
=
Color
.
red
;
Logged
mishaps
Jr. Member
Thank You
-Given: 0
-Receive: 0
Posts: 65
Re: UIButton.UpdateColor();
«
Reply #6 on:
March 12, 2014, 07:47:43 AM »
awesome man thanks for the detailed explanation!
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
UIButton.UpdateColor();