2D Toolkit Forum

2D Toolkit => Support => Topic started by: Clet_ on October 09, 2013, 07:38:20 pm

Title: Disabling UIItem
Post by: Clet_ on October 09, 2013, 07:38:20 pm
I must be missing something, but I cannot seem to find an easy way to disable a UIItem.
As for example, I want a certain basic button (UIItem) that have a child sprite (UITweenItem). At a certain point, I want to disable this button, which means that the player would still see it, but it won't be clickable, no tweening, no callback.

As far as I checked, there is no explicit way to do it. I tried to unregister the button callbacks, which worked, but the button still tweened when clicked. I tried to switch the button on  a layer that is not used by the UIManager.raycastLayerMask, but this member did not seem to affect the raycasting, since every buttons are clickable wether the layer mask is set to Nothing or to everything. THe other option is to set UIManager.inputEnabled = false, but this turns off EVERYTHING, which is not the desired behaviour in my case.

Am I missing something? There must be an easy way to do something as I explained, since it seems very basic to me, and 2D Toolkit is a very deep, very good Unity plugin.

Regards
Title: Re: Disabling UIItem
Post by: Clet_ on October 09, 2013, 07:40:22 pm
I just realized that I could turn the collider off, and this would work just fine, but is there a native functionality that allow UIItem disabling?
Title: Re: Disabling UIItem
Post by: unikronsoftware on October 10, 2013, 09:11:32 am
Hi there isn't at the moment, as we've never needed it (until quite recently, I might add). We'll be adding a new state to the UIItem to disable it, and some supporting classes to make the element look disabled, grayed, etc.
Title: Re: Disabling UIItem
Post by: hawken on January 09, 2014, 04:37:38 am
I'm also interested in this feature  :D

I have UI items that overlay others (popups etc) and need an easy way to disable UI items when they are being covered.

thanks,
Title: Re: Disabling UIItem
Post by: unikronsoftware on January 09, 2014, 10:41:51 am
@hawken -
You can attach a collider to the overlay background to occlude UI items in the background.
Title: Re: Disabling UIItem
Post by: ccampama on January 13, 2015, 10:44:32 pm
Hi! I would like to know if there is something to make a UTItem look disabled/grayed out yet. I know that over a year has passed since the last post in this topic, but I really needed it by now. Thank you in advance!
Title: Re: Disabling UIItem
Post by: unikronsoftware on January 14, 2015, 10:51:04 am
No there isn't. You can create a new behaviour that will show / hide the correct item (and enable/disable the uiitem) based on state, thats probably the best way to do this.