当前位置: 首页>>代码示例>>C#>>正文


C# AnimationClip.SampleAnimation方法代码示例

本文整理汇总了C#中UnityEngine.AnimationClip.SampleAnimation方法的典型用法代码示例。如果您正苦于以下问题:C# AnimationClip.SampleAnimation方法的具体用法?C# AnimationClip.SampleAnimation怎么用?C# AnimationClip.SampleAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.AnimationClip的用法示例。


在下文中一共展示了AnimationClip.SampleAnimation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Awake

    void Awake()
    {
        rotater = transform.GetChild(0);

        animationClip =animation.GetClip("Loop_Animation");
        animationClip.SampleAnimation(animation.gameObject, 0f);

        length = animationClip.length;
    }
开发者ID:fanfreeman,项目名称:FunCarPipe,代码行数:9,代码来源:PipeItemRabbit.cs

示例2: ExportSkeletonAnimationClipData

        private static void ExportSkeletonAnimationClipData(Animator animator, bool autoPlay, BabylonSkeleton skeleton, Transform[] bones, BabylonMesh babylonMesh, AnimationClip clip)
        {
            var frameTime = 1.0f / clip.frameRate;
            int animationFrameCount = (int)(clip.length * clip.frameRate);

            if (autoPlay)
            {
                babylonMesh.autoAnimate = true;
                babylonMesh.autoAnimateFrom = 0;
                babylonMesh.autoAnimateTo = animationFrameCount;
                babylonMesh.autoAnimateLoop = true;
            }

            foreach (var bone in skeleton.bones)
            {
                var keys = new List<BabylonAnimationKey>();
                var transform = bones.Single(b => b.name == bone.name);

                AnimationMode.BeginSampling();
                for (var i = 0; i < animationFrameCount; i++)
                {
                    clip.SampleAnimation(animator.gameObject, i * frameTime);

                    var local = (transform.parent.localToWorldMatrix.inverse * transform.localToWorldMatrix);
                    float[] matrix = new[] {
                        local[0, 0], local[1, 0], local[2, 0], local[3, 0],
                        local[0, 1], local[1, 1], local[2, 1], local[3, 1],
                        local[0, 2], local[1, 2], local[2, 2], local[3, 2],
                        local[0, 3], local[1, 3], local[2, 3], local[3, 3]
                    };

                    var key = new BabylonAnimationKey
                    {
                        frame = i,
                        values = matrix,
                    };
                    keys.Add(key);
                }
                AnimationMode.EndSampling();

                var babylonAnimation = new BabylonAnimation
                {
                    name = bone.name + "Animation",
                    property = "_matrix",
                    dataType = (int)BabylonAnimation.DataType.Matrix,
                    loopBehavior = (int)BabylonAnimation.LoopBehavior.Cycle,
                    framePerSecond = (int)clip.frameRate,
                    keys = keys.ToArray()
                };

                bone.animation = babylonAnimation;
            }
        }
开发者ID:Temechon,项目名称:Babylon.js,代码行数:53,代码来源:SceneBuilder.Animations.cs

示例3: _FindPoints

    private SkillData _FindPoints( AnimationClip clip, float interval)
    {
        var data = new SkillData();

        var go = _Player as GameObject;

        var marks = go.GetComponentsInChildren<DeterminationExportMark>();
        var markLeft = (from m in marks where m.Part == DeterminationExportMark.PART.LEFT select m).Single();
        var markRight = (from m in marks where m.Part == DeterminationExportMark.PART.RIGHT select m).Single();
        var markRoot = (from m in marks where m.Part == DeterminationExportMark.PART.ROOT select m).Single();
        var len = clip.length;

        List<Vector2> left = new List<Vector2>();
        List<Vector2> right = new List<Vector2>();
        List<Translate> root = new List<Translate>();

        float eulerAngle = go.transform.rotation.eulerAngles.y;
        var rootPosition = new Vector2(go.transform.position.x, go.transform.position.z);
        var basePosition = markRoot.Position;
        Debug.Log("basePosition  : " + basePosition);
        for (var i = 0.0f ; i < len; i += interval)
        {
            clip.SampleAnimation(go, i);

            var currentposition = markRoot.Position - basePosition ;
            var position = currentposition;
            var y = go.transform.rotation.eulerAngles.y;
            var t = new Translate()
            {
                Position = new Regulus.CustomType.Vector2(position.x, position.y),
                Rotation = eulerAngle - y
            };

            root.Add(t);
            eulerAngle = y;
            if (i >= _BeginTime && i <= _EndTime)
            {
                left.Add(markLeft.Position - rootPosition  );

                right.Add(markRight.Position - rootPosition );
            }
        }
        data.Lefts = (from l in left select new Regulus.CustomType.Vector2(l.x, l.y)).ToArray();
        data.Rights = (from r in right select new Regulus.CustomType.Vector2(r.x, r.y)).ToArray();
        data.Roots = root.ToArray();
        data.Total = len;
        data.Begin = _BeginTime;
        data.End = _EndTime;

        return data;
    }
开发者ID:jiowchern,项目名称:ItIsNotAGame-FrontEnd,代码行数:51,代码来源:Recorder.cs


注:本文中的UnityEngine.AnimationClip.SampleAnimation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。