UIButton.UpdateColor C# (CSharp) Method

UpdateColor() public method

Update the button's color to either enabled or disabled state.
public UpdateColor ( bool shouldBeEnabled, bool immediate ) : void
shouldBeEnabled bool
immediate bool
return void
	public void UpdateColor (bool shouldBeEnabled, bool immediate)
	{
		if (tweenTarget)
		{
			if (!mStarted)
			{
				mStarted = true;
				Init();
			}

			Color c = shouldBeEnabled ? defaultColor : disabledColor;
			TweenColor tc = TweenColor.Begin(tweenTarget, 0.15f, c);

			if (immediate)
			{
				tc.color = c;
				tc.enabled = false;
			}
		}
	}
}

Usage Example

示例#1
0
    public IEnumerator Cooldown(float cooldown)
    {
        //Deactivate the Barrier button and update Color to Disable
        button.isEnabled = false;
        button.UpdateColor(true);
        slider.gameObject.SetActive(true);
        StartCoroutine(FillSlider(cooldown));
        currentCoolDown = cooldown;
        initialCooldown = cooldown;

        while (currentCoolDown > 0)
        {
            //Update Label with localized text each second
            label.text       = Localization.Get("Wait") + " " + Mathf.CeilToInt(currentCoolDown).ToString() + "s";
            currentCoolDown -= 1;
            //Wait for a second, then return to start of While
            yield return(new WaitForSeconds(1));
        }

        if (this != null && gameObject != null)
        {
            GetComponent <Collider2D>().enabled = false;
            yield return(null);
        }

        //If cooldown <= 0
        CooldownFinished();
        yield return(new WaitForSeconds(0.20f));

        if (this != null && gameObject != null)
        {
            GetComponent <Collider2D>().enabled = true;
            yield return(null);
        }
    }
All Usage Examples Of UIButton::UpdateColor