// STATIC CONSTRUCTORS: -------------------------------------------------------------------

        public static PlayableStateCharacter Create <TInput0, TOutput>(
            CharacterState stateAsset, AvatarMask avatarMask,
            CharacterAnimation character, int layer,
            double startTime, float fade, float speed, float weight,
            ref PlayableGraph graph, ref TInput0 input0, ref TOutput output)
            where TInput0 : struct, IPlayable
            where TOutput : struct, IPlayable
        {
            PlayableStateCharacter state = new PlayableStateCharacter(
                stateAsset, avatarMask,
                character, layer,
                fade, speed, weight
                );

            AnimatorControllerPlayable input1 = AnimatorControllerPlayable.Create(
                graph,
                stateAsset.GetRuntimeAnimatorController()
                );

            input1.SetTime(startTime);
            input1.SetSpeed(speed);

            state.Setup(ref graph, ref input0, ref input1, ref output);
            return(state);
        }
        public static PlayableStateCharacter CreateBefore(
            CharacterState stateAsset, AvatarMask avatarMask,
            CharacterAnimation character, int layer,
            double startTime, float fade, float speed, float weight,
            ref PlayableGraph graph, PlayableBase next)
        {
            PlayableStateCharacter state = new PlayableStateCharacter(
                stateAsset, avatarMask,
                character, layer,
                fade, speed, weight
                );

            AnimatorControllerPlayable input1 = AnimatorControllerPlayable.Create(
                graph,
                stateAsset.GetRuntimeAnimatorController()
                );

            if (stateAsset.enterClip != null)
            {
                float offsetTime = Mathf.Max(0.15f, fade);
                input1.SetDelay(offsetTime);
            }

            input1.SetTime(startTime);
            input1.SetSpeed(speed);

            state.Setup(ref graph, ref input1, next);
            return(state);
        }
Example #3
0
        public static PlayableStateCharacter CreateAfter(
            CharacterState stateAsset, AvatarMask avatarMask,
            CharacterAnimation character, int layer,
            double startTime, float fade, float speed, float weight,
            ref PlayableGraph graph, PlayableBase previous,
            params PlayableGesture.Parameter[] parameters)
        {
            PlayableStateCharacter state = new PlayableStateCharacter(
                stateAsset, avatarMask,
                character, layer,
                fade, speed, weight
                );

            AnimatorControllerPlayable input1 = AnimatorControllerPlayable.Create(
                graph,
                stateAsset.GetRuntimeAnimatorController()
                );

            foreach (PlayableGesture.Parameter parameter in parameters)
            {
                input1.SetFloat(parameter.id, parameter.value);
            }

            if (stateAsset.enterClip != null)
            {
                float offsetTime = Mathf.Max(0.15f, fade);
                input1.SetDelay(offsetTime);
            }

            input1.SetTime(startTime);
            input1.SetSpeed(speed);

            state.Setup(ref graph, previous, ref input1);
            return(state);
        }
Example #4
0
        // INITIALIZERS: --------------------------------------------------------------------------

        public CharacterAnimation(CharacterAnimator characterAnimator, CharacterState defaultState)
        {
            this.characterAnimator = characterAnimator;
            this.SetupTopology(defaultState == null
                ? null
                : defaultState.GetRuntimeAnimatorController()
                               );
        }
Example #5
0
        // INITIALIZERS: --------------------------------------------------------------------------

        public CharacterAnimation(CharacterAnimator characterAnimator, CharacterState defaultState = null)
        {
            this.characterAnimator = characterAnimator;
            this.runtimeController = defaultState != null
                ? defaultState.GetRuntimeAnimatorController()
                : characterAnimator.animator.runtimeAnimatorController;

            this.Setup();
        }
Example #6
0
 public void SetState(CharacterState stateAsset, AvatarMask avatarMask,
                      float weight, float time, float speed, Layer layer)
 {
     stateAsset.StartState(this);
     this.states[(int)layer].stateAsset = stateAsset;
     this.SetState(
         stateAsset.GetRuntimeAnimatorController(), avatarMask,
         weight, time, speed, layer
         );
 }
Example #7
0
        // STATIC CONSTRUCTORS: -------------------------------------------------------------------

        public static PlayableStateCharacter Create <TInput0, TOutput>(
            CharacterState stateAsset, AvatarMask avatarMask,
            CharacterAnimation character, int layer,
            double startTime, float fade, float speed, float weight,
            ref PlayableGraph graph, ref TInput0 input0, ref TOutput output,
            params PlayableGesture.Parameter[] parameters)
            where TInput0 : struct, IPlayable
            where TOutput : struct, IPlayable
        {
            PlayableStateCharacter state = new PlayableStateCharacter(
                stateAsset, avatarMask,
                character, layer,
                fade, speed, weight
                );

            AnimatorControllerPlayable input1 = AnimatorControllerPlayable.Create(
                graph,
                stateAsset.GetRuntimeAnimatorController()
                );

            foreach (PlayableGesture.Parameter parameter in parameters)
            {
                input1.SetFloat(parameter.id, parameter.value);
            }

            // Obsolete :-(
            // if (stateAsset.enterClip != null)
            // {
            //     float offsetTime = Mathf.Max(0.15f, fade);
            //     input1.SetDelay(offsetTime);
            // }

            input1.SetTime(startTime);
            input1.SetSpeed(speed);

            state.Setup(ref graph, ref input0, ref input1, ref output);
            return(state);
        }
        public static PlayableStateCharacter CreateAfter(
            CharacterState stateAsset, AvatarMask avatarMask,
            CharacterAnimation character, int layer,
            double startTime, float fade, float speed, float weight,
            ref PlayableGraph graph, PlayableBase previous)
        {
            PlayableStateCharacter state = new PlayableStateCharacter(
                stateAsset, avatarMask,
                character, layer,
                fade, speed, weight
                );

            AnimatorControllerPlayable input1 = AnimatorControllerPlayable.Create(
                graph,
                stateAsset.GetRuntimeAnimatorController()
                );

            input1.SetTime(startTime);
            input1.SetSpeed(speed);

            state.Setup(ref graph, previous, ref input1);
            return(state);
        }