コード例 #1
0
    public ActionAnimationHandler(AnimationLayerMixerPlayable mixer, ActionAnimationDefinition[] actionAnimationDefs)
    {
        if (actionAnimationDefs == null)
        {
            return;
        }

        m_mixer = mixer;
        foreach (var def in actionAnimationDefs)
        {
            if (def.animation == null)
            {
                continue;
            }

            if (m_actionAnimations.ContainsKey(def.action))
            {
                continue;
            }

            ActionAnimation actionAnim = new ActionAnimation();
            actionAnim.animation = AnimationClipPlayable.Create(mixer.GetGraph(), def.animation);
            actionAnim.animation.SetApplyFootIK(false);
            actionAnim.animation.SetDuration(def.animation.length);
            actionAnim.port = mixer.AddInput(actionAnim.animation, 0);
            actionAnim.restartTimeOffset = def.restartTimeOffset;
            mixer.SetLayerAdditive((uint)actionAnim.port, true);
            m_actionAnimations.Add(def.action, actionAnim);
        }
    }
コード例 #2
0
        //============================================================================================
        /**
        *  @brief Constructor for the MxMLayer class. Sets up all initial values and creates the layer's
        *  mixer 
        *  
        *  @param [int] a_id - the layer id (lowest layer value is 2 for MxMLayers)
        *  @param [int] a_maxClips - the maximum number of clips that can be blended on this layer
        *  @param [ref PlayableGraph] a_playableGraph - the playable graph that this layer lives on
        *  @param [AnimationClip] a_clip - the starting animation clip to use for this layer.
        *  @param [AvatarMask] a_mask - the mask to use with this player (Default null)
        *  @param [float] a_weight - the starting weight of this layer (Default 0)
        *  @param [bool] a_additive - whether the layer is additive or not (Default false)
        *         
        *********************************************************************************************/
        public MxMLayer(int a_id, int a_maxClips, ref AnimationLayerMixerPlayable a_layerMixer, 
            AnimationClip a_clip, AvatarMask a_mask = null, float a_weight = 0f, bool a_additive = false)
        {
            Assert.IsNotNull(a_clip, "Error: Attempting to create an MxMLayer with null AnimationClip");

            if (!a_layerMixer.IsValid())
                Debug.LogError("Error: Attempting to create an MxMLayer with an invalid layerMixer.");

            m_playableGraph = a_layerMixer.GetGraph();
            m_layerMixer = a_layerMixer;
            PrimaryClip = a_clip;

            Id = a_id;
            MaxClips = a_maxClips;

            PrimaryInputId = 0;

            Mixer = AnimationMixerPlayable.Create(m_playableGraph, a_maxClips, true);
            var clipPlayable = AnimationClipPlayable.Create(m_playableGraph, PrimaryClip);

            m_layerMixer.ConnectInput(Id, Mixer, 0);

            Mixer.ConnectInput(0, clipPlayable, 0);
            Mixer.SetInputWeight(0, 1f);

            Mask = a_mask;

            m_layerMixer.SetLayerAdditive((uint)Id, a_additive);
            m_layerMixer.SetInputWeight(Id, Mathf.Clamp01(a_weight));

            SubLayerWeights = new float[MaxClips];
            SubLayerWeights[0] = 1f;
        }
コード例 #3
0
        //============================================================================================
        /**
        *  @brief Constructor for the MxMLayer class which takes a playable instead of an animation clip. 
        *  Sets up all initial values and creates the layer's mixer.
        *  
        *  @param [int] a_id - the layer id (lowest layer value is 2 for MxMLayers)
        *  @param [int] a_maxClips - the maximum number of clips that can be blended on this layer
        *  @param [ref PlayableGraph] a_playableGraph - the playable graph that this layer lives on
        *  @param [Playable] a_playable - the playable to use for this layer
        *  @param [AvatarMask] a_mask - the mask to use with this player (Default null)
        *  @param [float] a_weight - the starting weight of this layer (Default 0)
        *  @param [bool] a_additive - whether the layer is additive or not (Default false)
        *         
        *********************************************************************************************/
        public MxMLayer(int a_id, ref AnimationLayerMixerPlayable a_layerMixer,
           Playable a_playable, AvatarMask a_mask = null, float a_weight = 0f, bool a_additive = false)
        {
            if (!a_playable.IsValid())
                Debug.LogError("Error: Attempting to create an MxMLayer with an invalid playable");

            if (!a_layerMixer.IsValid())
                Debug.LogError("Error: Attempting to create an MxMLayer with an invalid layerMixer.");

            m_layerMixer = a_layerMixer;
            m_playableGraph = m_layerMixer.GetGraph();

            Id = a_id;

            PrimaryInputId = 0;
            MaxClips = 1;

            m_layerMixer.ConnectInput(Id, a_playable, 0);

            Mask = a_mask;

            m_layerMixer.SetLayerAdditive((uint)Id, a_additive);
            m_layerMixer.SetInputWeight(Id, Mathf.Clamp01(a_weight));

            SubLayerWeights = new float[1];
            SubLayerWeights[0] = 1f;
        }
コード例 #4
0
    public AimVerticalHandler(AnimationLayerMixerPlayable mixer, AnimationClip animAimDownToUp)
    {
        // Aim
        m_animAim = AnimationClipPlayable.Create(mixer.GetGraph(), animAimDownToUp);
        m_animAim.SetApplyFootIK(false);
        m_animAim.Pause();
        m_aimTimeFactor = animAimDownToUp.length / 180.0f;

        m_port = mixer.AddInput(m_animAim, 0);
        mixer.SetLayerAdditive((uint)m_port, true);
        mixer.SetInputWeight(m_port, 1.0f);
    }