public override Playable GeneratePlayable(PlayableGraph graph, Dictionary <string, List <BlendTreeController1D> > varTo1DBlendControllers, Dictionary <string, List <BlendTreeController2D> > varTo2DBlendControllers, Dictionary <string, float> blendVars) { var treeMixer = AnimationMixerPlayable.Create(graph, blendTree.Count, true); if (blendTree.Count == 0) { return(treeMixer); } Action <float> setVar1 = val => blendVars[blendVariable] = val; Action <float> setVar2 = val => blendVars[blendVariable2] = val; var controller = new BlendTreeController2D(blendVariable, blendVariable2, treeMixer, blendTree.Count, setVar1, setVar2); varTo2DBlendControllers.GetOrAdd(blendVariable).Add(controller); varTo2DBlendControllers.GetOrAdd(blendVariable2).Add(controller); blendVars[blendVariable] = 0; blendVars[blendVariable2] = 0; for (int j = 0; j < blendTree.Count; j++) { var blendTreeEntry = blendTree[j]; var clipPlayable = AnimationClipPlayable.Create(graph, blendTreeEntry.clip); clipPlayable.SetSpeed(speed); graph.Connect(clipPlayable, 0, treeMixer, j); controller.Add(j, blendTreeEntry.threshold1, blendTreeEntry.threshold2); } treeMixer.SetInputWeight(0, 1f); return(treeMixer); }
public override Playable GeneratePlayable(PlayableGraph graph, Dictionary <string, List <BlendTreeController1D> > varTo1DBlendControllers, Dictionary <string, List <BlendTreeController2D> > varTo2DBlendControllers, List <BlendTreeController2D> all2DControllers) { var treeMixer = AnimationMixerPlayable.Create(graph, blendTree.Count, true); treeMixer.SetPropagateSetTime(true); if (blendTree.Count == 0) { return(treeMixer); } var controller = new BlendTreeController2D(blendVariable, blendVariable2, treeMixer, blendTree.Count); all2DControllers.Add(controller); varTo2DBlendControllers.GetOrAdd(blendVariable).Add(controller); varTo2DBlendControllers.GetOrAdd(blendVariable2).Add(controller); for (int j = 0; j < blendTree.Count; j++) { var blendTreeEntry = blendTree[j]; var clipPlayable = AnimationClipPlayable.Create(graph, GetClipToUseFor(blendTreeEntry.clip)); clipPlayable.SetApplyFootIK(true); clipPlayable.SetSpeed(speed); graph.Connect(clipPlayable, 0, treeMixer, j); controller.AddThresholdsForClip(j, blendTreeEntry.threshold1, blendTreeEntry.threshold2); } controller.OnAllThresholdsAdded(); controller.SetInitialValues(0f, 0f); return(treeMixer); }