/************************************************************************************************************************/

        private void OnEnable()
        {
            // 因为Float1ControllerTransition是一个可以在多个对象之间共享的转换资产,所以我们不能简单地访问_Controller.Transition.
            // 因为它只会保存最近播放的状态(只对一个实例是正确的,而对其他实例则不正确).

            // 相反,我们会在播放后立即获取状态.

            _Animancer.Play(_Controller);
            _State = _Controller.Transition.State;

            // Play方法返回的状态会做同样的事情,但它只返回一个基本的AnimancerState,我们需要一个Float1ControllerState来访问它下面的参数属性,
            // 所以我们需要对它进行类型转换:_State = (Float1ControllerState)_Animancer.Play(_Controller);
        }
Пример #2
0
        /************************************************************************************************************************/

        private void OnEnable()
        {
            // Since Float1ControllerTransition is a Transition Asset which can be shared among multiple objects, we
            // cannot simply access the _Controller.Transition.State whenever we want because it will only hold the
            // most recently played state (which will only be correct for one instance but not the others).

            // So instead, we grab the state right after playing it.

            _Animancer.Play(_Controller);
            _State = _Controller.Transition.State;

            // The state returned by the Play method would do the same thing, but it only returns a base AnimancerState
            // and we need a Float1ControllerState to access its Parameter property below so we would need to cast it:
            // _State = (Float1ControllerState)_Animancer.Play(_Controller);
        }