private static int ConvertSimpleDirectional2DBlendTree(BlendTree blendTree, Entity entity, EntityManager entityManager, BakeOptions bakeOptions) { if (!entityManager.HasComponent <BlendTree2DResource>(entity)) { entityManager.AddBuffer <BlendTree2DResource>(entity); } if (!entityManager.HasComponent <BlendTree2DMotionData>(entity)) { entityManager.AddBuffer <BlendTree2DMotionData>(entity); } var blendTreeResources = entityManager.GetBuffer <BlendTree2DResource>(entity); var blendTreeMotionData = entityManager.GetBuffer <BlendTree2DMotionData>(entity); var blendTreeIndex = blendTreeResources.Length; blendTreeResources.Add(new BlendTree2DResource { MotionCount = blendTree.children.Length, MotionStartIndex = blendTreeMotionData.Length }); for (int i = 0; i < blendTree.children.Length; i++) { var motionData = new BlendTree2DMotionData { MotionPosition = blendTree.children[i].position, 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); }
protected override void OneTimeSetUp() { base.OneTimeSetUp(); var motionData = new BlendTree2DMotionData[] { new BlendTree2DMotionData { MotionPosition = new float2(-2, 0), MotionSpeed = 0.8f, }, new BlendTree2DMotionData { MotionPosition = new float2(2, 0), MotionSpeed = 0.6f, }, new BlendTree2DMotionData { MotionPosition = new float2(0, 2), MotionSpeed = 0.4f, }, new BlendTree2DMotionData { MotionPosition = new float2(0, -2), MotionSpeed = 0.2f, }, }; m_BlendTree = BlendTreeBuilder.CreateBlendTree2DSimpleDirectional(motionData); }