示例#1
0
        protected virtual StatableCase DoStateTransition(StatableCase _newCase, TransitionType _type)
        {
            Color  tintColorForImage;
            Color  tintColorForText;
            Sprite transitionSprite;

            StatableCase oldCase = m_curCase;

            m_curCase = _newCase;

            m_TransitionForImage = _type;

            switch (_newCase)
            {
            case StatableCase.Normal:
                tintColorForImage = m_ColorsForImage.normalColor;
                tintColorForText  = m_ColorsForText.normalColor;
                transitionSprite  = null;
                break;

            case StatableCase.Selected:
                tintColorForImage = m_ColorsForImage.highlightedColor;
                tintColorForText  = m_ColorsForText.highlightedColor;
                transitionSprite  = m_SpriteState.highlightedSprite;
                break;

            case StatableCase.Pressed:
                tintColorForImage = m_ColorsForImage.pressedColor;
                tintColorForText  = m_ColorsForText.pressedColor;
                transitionSprite  = m_SpriteState.pressedSprite;
                break;

            case StatableCase.Disabled:
                tintColorForImage = m_ColorsForImage.disabledColor;
                tintColorForText  = m_ColorsForText.disabledColor;
                transitionSprite  = m_SpriteState.disabledSprite;
                break;

            default:
                tintColorForImage = Color.black;
                tintColorForText  = Color.black;
                transitionSprite  = null;
                break;
            }

            if (gameObject.activeInHierarchy)
            {
                switch (m_TransitionForImage)
                {
                case TransitionType.ColorTint:
                    StartColorTween(tintColorForImage * m_ColorsForImage.colorMultiplier, tintColorForText);
                    break;

                case TransitionType.SpriteSwap:
                    DoSpriteSwap(transitionSprite);

                    if (textComponent != null)
                    {
                        m_targetGraphicForText.canvasRenderer.SetColor(tintColorForText);
                    }
                    break;

                default:
                    m_targetGraphicForImage.canvasRenderer.SetColor(m_targetGraphicForImage.color);
                    m_targetGraphicForText.canvasRenderer.SetColor(m_targetGraphicForText.color);

                    if (image != null)
                    {
                        image.overrideSprite = null;
                    }
                    break;
                }
            }

            return(oldCase);
        }
示例#2
0
 public StatableCase SetStatableCase(StatableCase _newCase, TransitionType _type)
 {
     return(DoStateTransition(_newCase, _type));
 }
示例#3
0
 public StatableCase SetStatableCase(StatableCase _newCase)
 {
     return(DoStateTransition(_newCase, m_TransitionForImage));
 }
示例#4
0
        protected virtual StatableCase DoStateTransition(StatableCase _newCase, TransitionType _type)
        {
            Color  tintColor;
            Sprite transitionSprite;

            StatableCase oldCase = m_curCase;

            m_curCase = _newCase;

            m_Transition = _type;

            switch (_newCase)
            {
            case StatableCase.Normal:
                tintColor        = m_Colors.normalColor;
                transitionSprite = null;
                break;

            case StatableCase.Selected:
                tintColor        = m_Colors.highlightedColor;
                transitionSprite = m_SpriteState.highlightedSprite;
                break;

            case StatableCase.Pressed:
                tintColor        = m_Colors.pressedColor;
                transitionSprite = m_SpriteState.pressedSprite;
                break;

            case StatableCase.Disabled:
                tintColor        = m_Colors.disabledColor;
                transitionSprite = m_SpriteState.disabledSprite;
                break;

            default:
                tintColor        = Color.black;
                transitionSprite = null;
                break;
            }

            if (gameObject.activeInHierarchy)
            {
                switch (m_Transition)
                {
                case TransitionType.ColorTint:
                    StartColorTween(tintColor * m_Colors.colorMultiplier);
                    break;

                case TransitionType.SpriteSwap:
                    DoSpriteSwap(transitionSprite);
                    break;

                default:
                    m_targetGraphic.canvasRenderer.SetColor(m_targetGraphic.color);
                    if (image != null)
                    {
                        image.overrideSprite = null;
                    }
                    break;
                }
            }

            if (m_statableTransitionEvent != null)
            {
                m_statableTransitionEvent.Invoke(oldCase, _newCase, this);
            }

            return(oldCase);
        }