public int sourceLayerIndex = -1;   // -1代表无同步层
        // todo: editor编辑

        /// <summary>
        /// 在控制器中添加该层的所有动画
        /// </summary>
        /// <param name="playableAnimator"></param>
        /// <param name="layer"></param>
        public void AddStates(PlayableAnimator playableAnimator, int layer)
        {
            if (stateGroups != null)
            {
                for (int i = 0; i < stateGroups.Length; i++)
                {
                    stateGroups[i].AddStates(playableAnimator, layer);
                }
            }
        }
예제 #2
0
        public void AddStates(PlayableAnimator playableAnimator)
        {
            AddParameters(playableAnimator);

            for (int i = 0; i < stateLayers.Length; i++)
            {
                stateLayers[i].AddLayer(playableAnimator, i);
                stateLayers[i].AddStates(playableAnimator, i);
            }
        }
예제 #3
0
 void AddParameters(PlayableAnimator playableAnimator)
 {
     if (parameters != null && parameters.parameters != null)
     {
         var tlist = parameters.parameters;
         int tlen  = tlist.Length;
         for (int i = 0; i < tlen; i++)
         {
             var item = tlist[i];
             playableAnimator.StateController.Params.AddParameter(item);
         }
     }
 }
예제 #4
0
        public void AddStates(PlayableAnimator playableAnimator, int layer, string groupName = null)
        {
            PlayableStateController.BlendTreeConfig[] configs = new PlayableStateController.BlendTreeConfig[motions.Length];
            for (int i = 0; i < configs.Length; i++)
            {
                configs[i].clip      = motions[i].clip;
                configs[i].speed     = motions[i].speed;
                configs[i].threshold = motions[i].threshold;
            }
            if (playableAnimator.StateController.Params.Contains(parameter) == false)
            {
                playableAnimator.StateController.Params.AddFloat(parameter);
            }

            playableAnimator.AddBlendTree(configs, parameter, stateName, groupName, layer);
        }
            public void AddState(PlayableAnimator playableAnimator, string groupName, int layer)
            {
                string tstateName = string.IsNullOrEmpty(stateName) ? clip.name : stateName;

                PlayableStateController.StateInfo tinfo = playableAnimator.AddState(clip, tstateName, groupName, layer);
                tinfo.speed = speed;
                if (transtions != null && transtions.Length > 0)
                {
                    AnimatorTransition[] ttransObj = new AnimatorTransition[transtions.Length];
                    tinfo.transtions = ttransObj;
                    for (int i = 0; i < ttransObj.Length; i++)
                    {
                        ttransObj[i] = new AnimatorTransition(playableAnimator.StateController.Params, transtions[i], i);
                    }
                }
            }
        public void AddStates(PlayableAnimator playableAnimator, int layer)
        {
            if (blendTrees != null)
            {
                for (int i = 0; i < blendTrees.Length; i++)
                {
                    blendTrees[i].AddStates(playableAnimator, layer, groupName);
                }
            }

            if (motions != null)
            {
                for (int i = 0; i < motions.Length; i++)
                {
                    motions[i].AddState(playableAnimator, groupName, layer);
                }
            }
        }
        /// <summary>
        /// 在控制器中添加层
        /// </summary>
        /// <param name="playableAnimator"></param>
        /// <param name="layer"></param>
        public void AddLayer(PlayableAnimator playableAnimator, int layer)
        {
            var ctrl = playableAnimator.StateController;

            if (layer > 0)  // 0 为自动创建的默认层
            {
                ctrl.AddLayer(layer);
            }

            var layerInstance = ctrl.GetLayer(layer);

            if (layerInstance != null)
            {
                layerInstance.IKPass         = _IKPass;
                layerInstance.SyncLayerIndex = sourceLayerIndex;
                layerInstance.IsAdditive     = isAdditive;
                layerInstance.timing         = timing;

                if (avatarMask != null)
                {
                    layerInstance.AvatarMask = avatarMask;
                }
            }
        }