public void AddStates(PlayableAnimator playableAnimator) { for (int i = 0; i < stateLayers.Length; i++) { stateLayers[i].AddLayer(playableAnimator, i); stateLayers[i].AddStates(playableAnimator, i); } }
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); } } }
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.ContainsFloat(parameter) == false) { playableAnimator.StateController.Params.AddFloat(parameter); } playableAnimator.AddBlendTree(configs, parameter, stateName, groupName, layer); }
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++) { var motion = motions[i]; string stateName = string.IsNullOrEmpty(motion.stateName) ? motion.clip.name : motion.stateName; playableAnimator.AddState(motion.clip, stateName, 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; } } }