How to change NGUI Imagebutton amount of sprite states

NGUI’s UIImageButton appears to only have three states, not including one for disabled, how could I add the disabled state to the image button?

please look that video and tell me what im thinking or doing wrong please.

using UnityEngine;

/// <summary>
/// Sample script showing how easy it is to implement a standard button that swaps sprites.
/// </summary>

[ExecuteInEditMode]
[AddComponentMenu("NGUI/UI/Image Button")]
public class UIImageButton : MonoBehaviour
{
	public UISprite target;
	public string normalSprite;
	public string hoverSprite;
	public string pressedSprite;

	void OnEnable ()
	{
		if (target != null)
		{
			target.spriteName = UICamera.IsHighlighted(gameObject) ? hoverSprite : normalSprite;
		}
	}

	void Start ()
	{
		if (target == null) target = GetComponentInChildren<UISprite>();
	}

	void OnHover (bool isOver)
	{
		if (enabled && target != null)
		{
			target.spriteName = isOver ? hoverSprite : normalSprite;
			target.MakePixelPerfect();
		}
	}

	void OnPress (bool pressed)
	{
		if (enabled && target != null)
		{
			target.spriteName = pressed ? pressedSprite : normalSprite;
			target.MakePixelPerfect();
		}
	}
}

So NGUI works by finding a collider and sending messages to it. All of the NGUI logic for button presses etc are in the UICamera script.

Enabled is an interesting state, if you look at UIButton you will see it implements it as “isEnabled” and in fact UIButton just manages it all internally. To be clear, you do not need a UIButton in order to have a button in NGUI!

So if you want to enable some other state you do so in response to the messages you receive in the script, but in the case of Enabled you script it yourself. Perhaps like this:

using UnityEngine;

[ExecuteInEditMode]
[AddComponentMenu("NGUI/UI/Image Button")]
public class UIImageButtonEx : MonoBehaviour
{
	public UISprite target;
	public string normalSprite;
	public string hoverSprite;
	public string pressedSprite;
    public string disabledSprite;
    public string clickedSprite;
    public bool isEnabled;
    bool _lastEnabled;

	void OnEnable ()
	{
		StartCoroutine(CheckForEnabled());
	}

    void OnDisable()
    {
          if(!string.IsNullOrEmpty(disabledSprite))
              target.spriteName = disabledSprite;
    }

    IEnumerator CheckForEnabled()
    {
          if(target)
                target.spriteName = isEnabled ?  (UICamera.IsHighlighted(gameObject) ? hoverSprite : normalSprite) : disabledSprite ;
          while(true)
          {
             
               if(target && _lastEnabled != isEnabled)
               {
                   _lastEnabled = isEnabled;
                   target.spriteName = isEnabled ?  (UICamera.IsHighlighted(gameObject) ? hoverSprite : normalSprite) : disabledSprite ;                      
               }
               yield return new WaitForSeconds(0.1f);
          }
    }

	void Awake ()
	{
		if (target == null) target = GetComponentInChildren<UISprite>();
            disabledSprite = !string.IsNullOrEmpty(disabledSprite) ? disabledSprite : normalSprite;
	}

    void OnClick()
    {
           if(target && !string.IsNullOrEmpty(clickedSprite))
           {
              StartCoroutine(ClickSprite());
           }
    }

    IEnumerator ClickSprite()
    {
         var former = target.spriteName;
         target.spriteName = clickedSprite;
         yield return new WaitForSeconds(0.6f);
         if(target.spriteName == clickedSprite)
               target.spriteName = former;

    }

	void OnHover (bool isOver)
	{
		if (enabled && target != null)
		{
			target.spriteName = isOver ? hoverSprite : normalSprite;
			target.MakePixelPerfect();
		}
	}

	void OnPress (bool pressed)
	{
		if (enabled && target != null)
		{
			target.spriteName = pressed ? pressedSprite : normalSprite;
			target.MakePixelPerfect();
		}
	}
}

I should point out that UICamera will still send the messages to the other scripts which would need to check the isEnabled property of this script to see if they should react. You could edit UICamera to make that not true.