Welcome,
Guest
. Please
login
or
register
.
May 12, 2025, 11:01:12 PM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
[bug] UIButton cannot change color to grey while isEnabled = false in OnClick
« previous
next »
Print
Pages: [
1
]
Author
Topic: [bug] UIButton cannot change color to grey while isEnabled = false in OnClick (Read 13396 times)
yuewah
Full Member
Thank You
-Given: 0
-Receive: 0
Posts: 180
[bug] UIButton cannot change color to grey while isEnabled = false in OnClick
«
on:
May 10, 2012, 10:34:17 PM »
UIButton cannot change color to grey while isEnabled = false is set inside OnClick
public
class
ButtonOnClick
:
MonoBehaviour
{
void
Start
(
)
{
//this.GetComponent<UIButton>().isEnabled = false;
}
void
OnClick
(
)
{
Debug
.
Log
(
"OnClick"
)
;
this
.
GetComponent
<
UIButton
>
(
)
.
isEnabled
=
false
;
}
}
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: [bug] UIButton cannot change color to grey while isEnabled = false in OnClick
«
Reply #1 on:
May 10, 2012, 11:09:51 PM »
Changing the state of a button from inside a callback that results from the state changing... iffy to begin with, but I'll have a look at it.
Logged
yuewah
Full Member
Thank You
-Given: 0
-Receive: 0
Posts: 180
Re: [bug] UIButton cannot change color to grey while isEnabled = false in OnClick
«
Reply #2 on:
May 11, 2012, 05:53:31 AM »
thank, actually, I just want to disable the Button when I click on it, the button is disabled, but the color didn't change to grey.
Logged
Nicki
Global Moderator
Hero Member
Thank You
-Given: 33
-Receive: 141
Posts: 1,768
Re: [bug] UIButton cannot change color to grey while isEnabled = false in OnClick
«
Reply #3 on:
May 11, 2012, 03:56:36 PM »
Assuming it's a UISprite on it.
public
class
ButtonOnClick
:
MonoBehaviour
{
void
OnClick
(
)
{
Debug
.
Log
(
"OnClick"
)
;
GetComponent
<
UISprite
>
(
)
.
color
=
Color
.
grey
;
//or (new Color(0.5f,0.5f,0.5f,1f)
gameObject
.
active
=
false
}
}
Better (slightly faster) to just have the reference to whatever widget inside the ButtonOnClick though.
Logged
yuewah
Full Member
Thank You
-Given: 0
-Receive: 0
Posts: 180
Re: [bug] UIButton cannot change color to grey while isEnabled = false in OnClick
«
Reply #4 on:
May 12, 2012, 01:38:33 PM »
@Nicki, thank for your reply, it is a workaround. The problem is UIButton.isEnabled is not work as expected.
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
[bug] UIButton cannot change color to grey while isEnabled = false in OnClick