Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Rafe on July 18, 2012, 06:56:20 PM

Title: UIImageButton Disabled Sprite Image?
Post by: Rafe on July 18, 2012, 06:56:20 PM
Hi,

Is there a way to display an image when the button is in a disabled state? I see:
normalSprite
hoverSprite
pressedSprite

I was hoping for
disabledSprite


Also, did I read correctly that the way to disable a button (still visible but no longer accepting input) is to disable the collider component?

Cheers,
Title: Re: UIImageButton Disabled Sprite Image?
Post by: ArenMook on July 18, 2012, 07:12:29 PM
Standard button has a disabled state. Image button does not. For the image button, simply place a sprite you want the button to look like when it's disabled in the same place as the button, and arrange its depth so that it's behind the button. Then when you "disable" the button, you will disable the game object the button is on, and enable your sprite instead.
Title: Re: UIImageButton Disabled Sprite Image?
Post by: Rafe on July 30, 2012, 02:28:46 AM
Hi Aren,

I found it easier to edit the UIImageButton script ad inspector to add a disabled sprite / behaviour. Would you like it for nGUI?

Implementation details:

WDYT?

Cheers.
Title: Re: UIImageButton Disabled Sprite Image?
Post by: ArenMook on July 30, 2012, 06:15:25 AM
Sure, you can also just attach it here in case someone else has similar desires.
Title: Re: UIImageButton Disabled Sprite Image?
Post by: Rafe on July 31, 2012, 02:16:00 AM
Here is the script and inspector.

It would be cool if your atlas sprite drop-down list would include an empty option, so once I sprite is set, it can be un-set. In the case of this button, you can just set the inactive image to anything if it isn't being used.

Please let me know if you are willing to roll this in to the next release. I know I just posted this in another spot but I really can't change 3rd part imports because doing an upgrade will wipe out custom changes. Our project has too many files to risk it. If this will remain as an attachment example, I need to refactor these to a custom type name so importing future updates won't overwrite.

Thanks again!
Title: Re: UIImageButton Disabled Sprite Image?
Post by: daveUnit9 on October 04, 2012, 06:39:33 AM
Hi Rafe,

Did you update this extension for the latest version of NGUI? I would also find it really useful but I get some errors when using it as the SpriteField interface has changed. I managed to fix all compile errors and the button briefly worked, but once I set 'disabled' to true it stopped working and hasn't worked again since! I'm new to NGUI so haven't been able to figure out a fix yet.

Thanks,
Dave
Title: Re: UIImageButton Disabled Sprite Image?
Post by: Rafe on October 04, 2012, 09:56:55 AM
I'll have to update and see how it goes.
Title: Re: UIImageButton Disabled Sprite Image?
Post by: invitado123 on February 27, 2013, 09:01:42 AM
Did you ever get to update this?
Title: Re: UIImageButton Disabled Sprite Image?
Post by: Rafe on February 27, 2013, 05:00:32 PM
Hi,

I do have it working. I'll dig it up and post it in the next day or two
Title: Re: UIImageButton Disabled Sprite Image?
Post by: Rafe on March 07, 2013, 01:11:31 AM
Hopefully I copy-&-pasted the types correctly when I renamed these files....

Title: Re: UIImageButton Disabled Sprite Image?
Post by: BehindTheStone on March 07, 2013, 03:20:28 AM
Do you work with PlayMaker? Even if you don't, you can do that:

You can just disable the UIImageButton-Behaviour in that certain state. I am doing it like this and it works fine.