2D Toolkit Forum

2D Toolkit => Support => Topic started by: habitoti on January 03, 2014, 12:10:06 pm

Title: Disabling a UIButton
Post by: habitoti on January 03, 2014, 12:10:06 pm
Hi,

I hope this is not a completely stupid question because maybe I just oversaw something obvious (again ;-):
How do I "officially" disable a custom button? I have a button type with my own button behavior (actually mostly copied from the tk2d toggle button). I use the event settings from the tk2dUIItem piece of the button (because I like the inspector), and this always fires that click event, even if I disable that component (from within my button behavior component). Looking into the code, there is no OnDisable implemented in tk2dUIItem to take out the onClick (etc.) events (like it is the case for the behavior components like Toggle Button etc.). So how can I make it ignore clicks for a controlled period?
Another option would be to hanlde the click myself in my behavior component, but I haven't found out how to use your nice SendMessage inspector in editor ;-) Would that be possible at all easily?

Thanks, habitoti
Title: Re: Disabling a UIButton
Post by: unikronsoftware on January 03, 2014, 12:17:58 pm
You can disable it by disabling the collider. Everything revolves around the collider getting hit in the ray cast, so disabling that will mean the button will be unresponsive.
Title: Re: Disabling a UIButton
Post by: habitoti on January 03, 2014, 12:39:51 pm
That's actually what I did so far, but it felt somehow "inelegant" and I thought I simply missed the right way to do it. Something like a SetEnabled(true/false) that makes any button act accordingly.

Thanks anyway, then I leave it that way.

Regards, habitoti