Exemplo n.º 1
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();
            }
        }
Exemplo n.º 2
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);
        }