コード例 #1
0
        // STATE METHODS: -------------------------------------------------------------------------

        public void SetState(AnimationClip animationClip, AvatarMask avatarMask,
                             float weight, float transition, float speed, int layer)
        {
            PlayableState prevPlayable;
            PlayableState nextPlayable;

            int insertIndex = this.GetSurroundingStates(layer,
                                                        out prevPlayable,
                                                        out nextPlayable
                                                        );

            if (prevPlayable == null && nextPlayable == null)
            {
                this.states.Add(PlayableStateClip.Create(
                                    animationClip, avatarMask, layer, 0f,
                                    transition, speed, weight,
                                    ref this.graph,
                                    ref this.mixerStatesInput,
                                    ref this.mixerStatesOutput
                                    ));
            }
            else if (prevPlayable != null)
            {
                if (prevPlayable.Layer == layer)
                {
                    prevPlayable.StretchDuration(transition);
                }

                this.states.Insert(insertIndex, PlayableStateClip.CreateAfter(
                                       animationClip, avatarMask, layer, 0f,
                                       transition, speed, weight,
                                       ref this.graph,
                                       prevPlayable
                                       ));
            }
            else if (nextPlayable != null)
            {
                this.states.Insert(insertIndex, PlayableStateClip.CreateBefore(
                                       animationClip, avatarMask, layer, 0f,
                                       transition, speed, weight,
                                       ref this.graph,
                                       nextPlayable
                                       ));
            }
        }