Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started 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,
-
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.
-
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:
- When disabled is set to true, the disabledSprite is displayed and the hover and click events are ignored.
- When disabled is set to False, it properly figures out if the hover or normal sprite is initially displayed.
- The inspector has a "Disabled State" toggle in case the button needs to begin in a disabled state. This updates in Edit mode keeping with nGUI's WYSIWYG
WDYT?
Cheers.
-
Sure, you can also just attach it here in case someone else has similar desires.
-
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!
-
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
-
I'll have to update and see how it goes.
-
Did you ever get to update this?
-
Hi,
I do have it working. I'll dig it up and post it in the next day or two
-
Hopefully I copy-&-pasted the types correctly when I renamed these files....
-
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.