Example #1
0
    public void ToggleColor()
    {
        if (!toggled)
        {
            if (rawImage != null)
            {
                rawImage.CrossFadeColor(activeColor, fadeTime * 1.2f, false, true);
            }
            else if (image != null)
            {
                image.CrossFadeColor(activeColor, fadeTime * 1.2f, false, true);
            }

            toggled = true;
        }
        else if (toggled)
        {
            if (colorOnce)
            {
                return;
            }

            if (rawImage != null)
            {
                rawImage.CrossFadeColor(Color.white, fadeTime * 1.2f, false, true);
            }
            else if (image != null)
            {
                image.CrossFadeColor(Color.white, fadeTime * 1.2f, false, true);
            }

            toggled = false;
        }
    }
    public void Toggle(Button button, Color toggleColor)
    {
        MaskableGraphic foregroundImage = button.GetComponent <Image>();

        if (!toggled)
        {
            foregroundImage.CrossFadeColor(toggleColor, fadeTime * 1.2f, false, true);
            button.GetComponent <ButtonImageColor>().toggled = true;
        }
        else if (toggled)
        {
            foregroundImage.CrossFadeColor(Color.white, fadeTime * 1.2f, false, true);
            button.GetComponent <ButtonImageColor>().toggled = false;
        }
    }