Example #1
0
    public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        _menuStateMachine = animator.GetComponent<AnimatorMenuStateMachine>();

        // this transition is going to a new scene
        if (!string.IsNullOrEmpty(sceneName) && Application.loadedLevelName != sceneName) {
            _menuStateMachine.FindNamedLevel(sceneName, OnLevelLoaded);
        } else {
            LoadView();
        }
    }
    //TODO: use singleton Template
    void Awake()
    {
        DontDestroyOnLoad (this);

        if (Instance == null)
        {
            Instance = this;
            _animator = GetComponent<Animator>();

            if (!string.IsNullOrEmpty(StartTrigger))
            {
                _animator.SetTrigger(StartTrigger);
                _animator.enabled = true;
            }
        }
        else if (Instance != this)
        {
            Destroy(gameObject);
        }
    }