Example #1
0
        protected virtual void DrawRemoveGUI()
        {
            EditorGUILayout.LabelField("Remove By Time", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();
            timeRange.x = EditorGUILayout.FloatField("Start Time", timeRange.x);
            timeRange.y = EditorGUILayout.FloatField("End Time", timeRange.y);
            EditorGUILayout.EndHorizontal();

            indexRange = KeyframeUtility.GetRangeByTime(asset.keyframes, timeRange);
            if (asset.keyframes.Count > 0 && timeRange.x <= asset.keyframes[indexRange.x].time)
            {
                indexRange.x -= 1;
            }

            GUI.enabled = false;
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.IntField("Start Index", indexRange.x + 1);
            EditorGUILayout.IntField("End Index", indexRange.y);
            EditorGUILayout.EndHorizontal();
            GUI.enabled = true;

            if (GUILayout.Button("Confirm"))
            {
                asset.keyframes.RemoveRange(indexRange.x + 1, indexRange.y - indexRange.x);
                EditorUtility.SetDirty(target);
                AssetDatabase.SaveAssets();
            }
        }
Example #2
0
        protected virtual void DrawRemoveGUI()
        {
            EditorGUILayout.LabelField("Remove By Time", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();
            startTime = EditorGUILayout.FloatField("Start Time", startTime);
            endTime   = EditorGUILayout.FloatField("End Time", endTime);
            EditorGUILayout.EndHorizontal();

            startIndex = KeyframeUtility.GetIndex(startTime, asset.keyframes);
            endIndex   = KeyframeUtility.GetIndex(endTime, asset.keyframes);
            if (asset.keyframes.Count > 0 && startTime <= asset.keyframes[startIndex].time)
            {
                startIndex -= 1;
            }

            GUI.enabled = false;
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.IntField("Start Index", startIndex + 1);
            EditorGUILayout.IntField("End Index", endIndex);
            EditorGUILayout.EndHorizontal();
            GUI.enabled = true;

            if (GUILayout.Button("Confirm"))
            {
                asset.keyframes.RemoveRange(startIndex + 1, endIndex - startIndex);
                EditorUtility.SetDirty(target);
                AssetDatabase.SaveAssets();
            }
        }
Example #3
0
        public override void OnBehaviourPause(Playable playable, FrameData info)
        {
            if (tempFrames.Count > 0)
            {
                KeyframeUtility.Replace(clip.keyframes, tempFrames);
#if UNITY_EDITOR
                UnityEditor.EditorUtility.SetDirty(clip);
#endif
            }
        }
Example #4
0
        public override void PrepareFrame(Playable playable, FrameData info)
        {
            if (keyframes == null || keyframes.Count == 0)
            {
                return;
            }
            float time       = (float)playable.GetTime();
            int   frameIndex = KeyframeUtility.GetIndex(time, keyframes);
            T     startFrame = keyframes[frameIndex];
            T     endFrame   = frameIndex >= keyframes.Count - 1 ? keyframes[frameIndex] : keyframes[frameIndex + 1];
            float process    = Mathf.InverseLerp(startFrame.time, endFrame.time, time);

            InterpolateFrame(startFrame, endFrame, process);
        }
Example #5
0
        public override void OnBehaviourPause(Playable playable, FrameData info)
        {
            if (tempFrames.Count > 0)
            {
#if UNITY_EDITOR
                UnityEditor.Undo.RegisterCompleteObjectUndo(clip, "Record " + typeof(T).Name);
#endif
                KeyframeUtility.Replace(clip.keyframes, tempFrames);
#if UNITY_EDITOR
                UnityEditor.EditorUtility.SetDirty(clip);
                UnityEditor.AssetDatabase.SaveAssets();
#endif
            }
            Clear();
        }