protected override void OneTimeSetUp() { base.OneTimeSetUp(); var motionData = new BlendTree1DMotionData[] { new BlendTree1DMotionData { MotionThreshold = 0.2f, MotionSpeed = 1.0f }, new BlendTree1DMotionData { MotionThreshold = 0.4f, MotionSpeed = 0.8f }, new BlendTree1DMotionData { MotionThreshold = 0.6f, MotionSpeed = 0.6f }, new BlendTree1DMotionData { MotionThreshold = 0.8f, MotionSpeed = 0.4f }, new BlendTree1DMotionData { MotionThreshold = 1.0f, MotionSpeed = 0.2f }, }; m_BlendTree = BlendTreeBuilder.CreateBlendTree(motionData); }
private static int ConvertBlendTree1D(BlendTree blendTree, Entity entity, EntityManager entityManager, BakeOptions bakeOptions) { if (!entityManager.HasComponent <BlendTree1DResource>(entity)) { entityManager.AddBuffer <BlendTree1DResource>(entity); } if (!entityManager.HasComponent <BlendTree1DMotionData>(entity)) { entityManager.AddBuffer <BlendTree1DMotionData>(entity); } var blendTreeResources = entityManager.GetBuffer <BlendTree1DResource>(entity); var blendTreeMotionData = entityManager.GetBuffer <BlendTree1DMotionData>(entity); var blendTreeIndex = blendTreeResources.Length; blendTreeResources.Add(new BlendTree1DResource { MotionCount = blendTree.children.Length, MotionStartIndex = blendTreeMotionData.Length }); for (int i = 0; i < blendTree.children.Length; i++) { var motionData = new BlendTree1DMotionData { MotionThreshold = blendTree.children[i].threshold, MotionSpeed = blendTree.children[i].timeScale, }; var clip = ClipBuilder.AnimationClipToDenseClip(blendTree.children[i].motion as AnimationClip); if (bakeOptions.NeedBaking) { clip = UberClipNode.Bake(bakeOptions.RigDefinition, clip, bakeOptions.ClipConfiguration, bakeOptions.SampleRate); } motionData.Motion.Clip = clip; blendTreeMotionData.Add(motionData); } return(blendTreeIndex); }