Exemple #1
0
        private void UpdateUI(GameObject container, ButtonTransitionStyle transition, IUIButtonEffect effect, IUIButtonEffect regularEffect)
        {
            if (!effect.isEnable)
            {
                return;
            }
            tmpSprite = null;
            bool isChangeColor = true;

            image = container.GetComponent <Image>();
            text  = container.GetComponent <Text>();
            if ((null == image && null == text))
            {
                return;
            }

            switch (transition)
            {
            case ButtonTransitionStyle.ColorSwap:
                tmpColor = effect.color;
                break;

            case ButtonTransitionStyle.ColorMultiplie:
                if (regularEffect.color.Equals(effect.color))
                {
                    tmpColor = effect.color;
                }
                else
                {
                    tmpColor = regularEffect.color * effect.color;
                }
                break;

            case ButtonTransitionStyle.SpriteSwap:
                tmpSprite     = effect.sprite != null ? effect.sprite : regularEffect.sprite;
                tmpColor      = effect.color;
                isChangeColor = false;
                break;

            default:
                return;

                break;
            }


            if (null != image)
            {
                if (null != tmpSprite)
                {
                    image.sprite = tmpSprite;
                }
                if (isChangeColor)
                {
                    image.color = tmpColor;
                }
            }
            else if (null != text)
            {
                text.color = tmpColor;
            }
        }