コード例 #1
0
    public override void Read(
        TagRecord _Tag
        , BinaryReader _GAFFileReader
        , ref GAFAnimationData _SharedData
        , ref GAFTimelineData _CurrentTimeline)
    {
        uint count = _GAFFileReader.ReadUInt32();

        for (uint i = 0; i < count; ++i)
        {
            string id = GAFReader.ReadString(_GAFFileReader);

            ushort start = _GAFFileReader.ReadUInt16();
            ushort end   = _GAFFileReader.ReadUInt16();

            var data = new GAFSequenceData(id, (uint)start, (uint)end);
            if (_CurrentTimeline == null)
            {
                _SharedData.rootTimeline.sequences.Add(data);
            }
            else
            {
                _CurrentTimeline.sequences.Add(data);
            }
        }
    }
コード例 #2
0
        protected override AnimationClip createAnimationClip(GAFTimelineData _Timeline, GAFSequenceData _Sequence, string _Path)
        {
            var animationClip = new AnimationClip()
            {
                frameRate = 30
                ,
                name = _Sequence.name
            };

            var framesCount = _Sequence.endFrame - _Sequence.startFrame + 1;
            var timeInterval = framesCount / animationClip.frameRate / framesCount;

            var time = 0f;
            var events = new AnimationEvent[framesCount];
            for (uint i = _Sequence.startFrame, j = 0; i <= _Sequence.endFrame; i++, j++)
            {
                var animationEvent = new AnimationEvent();
                animationEvent.functionName = i != _Sequence.startFrame ? "updateToFrameAnimator" : "updateToFrameAnimatorWithRefresh";
                animationEvent.intParameter = (int)i;
                animationEvent.time = time;

                events[j] = animationEvent;

                time += timeInterval;
            }

            var serializedObj = new SerializedObject(animationClip);
            var settings = serializedObj.FindProperty("m_AnimationClipSettings");
            var loopTime = settings.FindPropertyRelative("m_LoopTime");

            loopTime.boolValue = true;
            serializedObj.ApplyModifiedProperties();

            #if !UNITY_5
            AnimationUtility.SetAnimationType(animationClip, ModelImporterAnimationType.Generic);
            #endif
            AnimationUtility.SetAnimationEvents(animationClip, events);

            AssetDatabase.CreateAsset(animationClip, _Path);

            return animationClip;
        }
コード例 #3
0
        protected override AnimationClip createAnimationClip(GAFTimelineData _Timeline, GAFSequenceData _Sequence, string _Path)
        {
            var animationClip = new AnimationClip()
            {
                frameRate = 30
                ,
                name = _Sequence.name
            };

            var framesCount  = _Sequence.endFrame - _Sequence.startFrame + 1;
            var timeInterval = framesCount / animationClip.frameRate / framesCount;

            var time   = 0f;
            var events = new AnimationEvent[framesCount];

            for (uint i = _Sequence.startFrame, j = 0; i <= _Sequence.endFrame; i++, j++)
            {
                var animationEvent = new AnimationEvent();
                animationEvent.functionName = i != _Sequence.startFrame ? "updateToFrameAnimator" : "updateToFrameAnimatorWithRefresh";
                animationEvent.intParameter = (int)i;
                animationEvent.time         = time;

                events[j] = animationEvent;

                time += timeInterval;
            }

            var serializedObj = new SerializedObject(animationClip);
            var settings      = serializedObj.FindProperty("m_AnimationClipSettings");
            var loopTime      = settings.FindPropertyRelative("m_LoopTime");

            loopTime.boolValue = true;
            serializedObj.ApplyModifiedProperties();

#if !UNITY_5
            AnimationUtility.SetAnimationType(animationClip, ModelImporterAnimationType.Generic);
#endif
            AnimationUtility.SetAnimationEvents(animationClip, events);

            AssetDatabase.CreateAsset(animationClip, _Path);

            return(animationClip);
        }