コード例 #1
0
        public void Stop()
        {
            aniIndex    = -1;
            preAniIndex = -1;
            eventIndex  = -1;
            curFrame    = 0.0f;
            curProcess  = 0;

            cureState = null;
        }
コード例 #2
0
 public void PlayState(RuntimeAnimatorState pState)
 {
     if (pState == null)
     {
         Debug.LogError("Can't found tstate by hash " + pState);
         return;
     }
     if (pState.motionIndex >= 0)
     {
         cureState = pState;
         PlayAnimation(pState.motionIndex);
     }
 }
コード例 #3
0
 public void CrossFade(RuntimeAnimatorState pState, float duration)
 {
     if (pState == null)
     {
         Debug.LogError("Can't found tstate by hash " + pState);
         return;
     }
     if (pState.motionIndex >= 0)
     {
         cureState = pState;
         CrossFadeAnimation(pState.motionIndex, duration);
     }
 }
コード例 #4
0
        void UpdateState()
        {
            if (cureState == null || cureState.motionIndex != aniIndex)
            {
                return;
            }
            AnimationInfo info = aniInfo[aniIndex];

            var ttrans = cureState.CheckTransition(curProcess);

            if (ttrans != null)
            {
                RuntimeAnimatorState tstate = null;
                if (ttrans.destinationType == AssetTransitions.DestinationType.state)
                {
                    tstate = GetState(ttrans.destinationHashName, cureState.layerIndex, cureState.machineIndex);
                }
                else if (ttrans.destinationType == AssetTransitions.DestinationType.stateMachine)
                {
                    if (ttrans.destinationIndex == -1)
                    {
                        ttrans.destinationIndex = Layers[cureState.layerIndex].GetMachineIndex(ttrans.destinationHashName);
                    }
                    tstate = GetState(0, cureState.layerIndex, ttrans.destinationIndex);
                }

                if (tstate == null)
                {
                    Pause();
                }
                else
                {
                    CrossFade(tstate, ttrans.duration);
                }
            }
        }
        public override void InitNode(AnimationInstancing pAnimator)
        {
            var tpam = parameters;

            stateLength = machineInfo.stateInfos.Count;
            stateList   = new RuntimeAnimatorState[stateLength];
            for (int i = 0; i < stateLength; i++)
            {
                var item   = machineInfo.stateInfos[i];
                var tstate = new RuntimeAnimatorState(item)
                {
                    parameters = tpam
                };
                tstate.InitNode(pAnimator);

                if (tstate.nameHash == machineInfo.defaultHashName)
                {
                    defaultState = tstate;
                }
                stateList[i] = tstate;

                hashMap.Add(tstate.nameHash, i);
            }
        }