Example #1
0
 protected override void Awake()
 {
     base.Awake();
     stateView       = GetComponentInParent <StateView>();
     buttonAnimation = GetComponent <ButtonAnimation>();
     buttonAnimation?.SetOwner(this);
     buttonAnimation?.ChangeState(buttonAnimation.currentState);
 }
Example #2
0
    override public void Select()
    {
        var newPreviouslySelected = (EventSystem.current != null) ? EventSystem.current.currentSelectedGameObject : null;

        if (newPreviouslySelected != gameObject)
        {
            EventSystem.current.SetSelectedGameObject(gameObject);
        }

        if (newPreviouslySelected == gameObject || MenuCursor.instance == null)
        {
            if (IsPressed())
            {
                buttonAnimation.ChangeState(ButtonAnimation.state.Press);
            }
            else
            {
                buttonAnimation.ChangeState(ButtonAnimation.state.Select);
            }
        }
        base.Select();
    }
Example #3
0
    void SelectGameObject(GameObject target)
    {
        if (selectedGameObject != null)
        {
            Animator[]      animators       = selectedGameObject.GetComponentsInChildren <Animator>();
            ButtonAnimation buttonAnimation = selectedGameObject.GetComponent <ButtonAnimation>();
            for (int i = 0; i < animators.Length; i++)
            {
                animators[i].SetTrigger("exit");
            }
            if (buttonAnimation != null)
            {
                buttonAnimation.ChangeState(ButtonAnimation.state.Idle);
            }
        }

        if (highlightClip != null)
        {
            AudioInstance.PlayClipAtPoint(highlightClip, Vector3.zero);
        }

        selectedGameObject = target;
        if (target != null)
        {
            rt.SetParent(target.transform);
            rt.anchoredPosition = Vector2.zero;

            AnimatedButton animatedButton = selectedGameObject.GetComponent <AnimatedButton>();
            if (animatedButton != null)
            {
                animatedButton.Select();
            }
            else if (target.GetComponent <IPointerClickHandler>() != null)
            {
                Animator[] animators = target.GetComponentsInChildren <Animator>();
                for (int i = 0; i < animators.Length; i++)
                {
                    animators[i].SetTrigger("enter");
                }
            }
        }
        else
        {
            transform.position = new Vector2(-5000, -5000);
        }
    }