コード例 #1
0
 public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
 {
     dstManager.AddComponentData(entity, new AnimateTranslation
     {
         TranslationCurve = TranslationCurve.ToAnimationCurveBlobAssetRef()
     });
 }
コード例 #2
0
        public void TestBackwardCurveWithCache(float timeStep, int keyframeCount)
        {
            var animCurve = new UnityEngine.AnimationCurve();

            for (var i = 0; i < keyframeCount; ++i)
            {
                animCurve.AddKey(new UnityEngine.Keyframe(i, i * timeStep, Mathf.Infinity, Mathf.Infinity));
            }

            var curveBlob = animCurve.ToAnimationCurveBlobAssetRef();
            var curve     = new Unity.Animation.AnimationCurve();

            curve.SetAnimationCurveBlobAssetRef(curveBlob);

            Measure.Method(() =>
            {
                // The longer the time step, the more the cache gets reused.
                for (var t = keyframeCount * timeStep; t >= 0.0f; t -= 0.1f)
                {
                    AnimationCurveEvaluator.Evaluate(t, ref curve);
                }
            })
            .WarmupCount(1)
            .MeasurementCount(100)
            .Run();

            curveBlob.Dispose();
        }
コード例 #3
0
        public void TestLinearCurve500Precision(float time)
        {
            var animCurve = new UnityEngine.AnimationCurve();

            animCurve.AddKey(0f, 0f);
            animCurve.AddKey(500f, 1f);

            var keyframeCurve = animCurve.ToAnimationCurveBlobAssetRef();
            var eval          = AnimationCurveEvaluator.Evaluate(time, keyframeCurve);
            var expected      = time / 500f;

            Assert.IsTrue(NearlyEqual(expected, eval, kTolerance), $"Expected {expected:n6} but was {eval:n6}.");

            keyframeCurve.Dispose();
        }