diff options
| author | yum <yum.food.vr@gmail.com> | 2026-02-17 20:47:23 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2026-02-17 20:47:23 -0800 |
| commit | e7e681b82b9f5bd492d3975560d4939c5b03be32 (patch) | |
| tree | e84e1dd826be206db465a10e7ba8d9428d408656 /Scripts | |
| parent | 75c5679714c339fced0a3769fa768f8cb98806d9 (diff) | |
Fold: more animation bugfixes
Diffstat (limited to 'Scripts')
| -rwxr-xr-x | Scripts/Fold/Editor/FoldEditorWindow.cs | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/Scripts/Fold/Editor/FoldEditorWindow.cs b/Scripts/Fold/Editor/FoldEditorWindow.cs index 48bfe2b..7cfb8aa 100755 --- a/Scripts/Fold/Editor/FoldEditorWindow.cs +++ b/Scripts/Fold/Editor/FoldEditorWindow.cs @@ -249,13 +249,16 @@ public class FoldEditorWindow : EditorWindow { EditorGUILayout.BeginHorizontal(); - if (GUILayout.Button("Create Keyframe", GUILayout.Height(30))) + if (GUILayout.Button(new GUIContent("W", "Write keyframe at playhead"), GUILayout.Width(36), GUILayout.Height(36))) ApplyToMaterial(recordKeyframes: true); - if (GUILayout.Button("Delete Keyframe", GUILayout.Height(30), GUILayout.Width(120))) + if (GUILayout.Button(new GUIContent("R", "Read animation values at playhead into editor"), GUILayout.Width(36), GUILayout.Height(36))) + ReadFromPlayhead(); + + if (GUILayout.Button(new GUIContent("X", "Delete keyframe at playhead"), GUILayout.Width(36), GUILayout.Height(36))) DeleteKeyframeAtCurrentTime(); - if (GUILayout.Button("Clear All", GUILayout.Height(30), GUILayout.Width(80))) + if (GUILayout.Button(new GUIContent("C", "Clear all operations"), GUILayout.Width(36), GUILayout.Height(36))) { if (EditorUtility.DisplayDialog("Clear All Operations", "Remove all operations from the pipeline?", "Clear", "Cancel")) @@ -272,13 +275,13 @@ public class FoldEditorWindow : EditorWindow EditorGUILayout.Space(3); EditorGUILayout.BeginHorizontal(); - if (GUILayout.Button(new GUIContent("<", "Retreat playhead"), GUILayout.Width(30), GUILayout.Height(20))) + if (GUILayout.Button(new GUIContent("<", "Retreat playhead"), GUILayout.Width(36), GUILayout.Height(36))) AdvancePlayhead(-frameStep); - frameStep = EditorGUILayout.IntField(frameStep, GUILayout.Width(40)); + frameStep = EditorGUILayout.IntField(frameStep, GUILayout.Width(40), GUILayout.Height(36)); if (frameStep < 1) frameStep = 1; - if (GUILayout.Button(new GUIContent(">", "Advance playhead"), GUILayout.Width(30), GUILayout.Height(20))) + if (GUILayout.Button(new GUIContent(">", "Advance playhead"), GUILayout.Width(36), GUILayout.Height(36))) AdvancePlayhead(frameStep); - if (GUILayout.Button(new GUIContent("x", "Snap to nearest keyframe"), GUILayout.Width(30), GUILayout.Height(20))) + if (GUILayout.Button(new GUIContent("Q", "Quantize: snap to nearest keyframe"), GUILayout.Width(36), GUILayout.Height(36))) SnapToNearestKeyframe(); GUILayout.FlexibleSpace(); EditorGUILayout.LabelField($"Operations: {operations.Count}/16", EditorStyles.miniLabel); @@ -376,6 +379,20 @@ public class FoldEditorWindow : EditorWindow #region Animation Recording + void ReadFromPlayhead() + { + if (!TryGetAnimationWindowState(out var clip, out float time)) + return; + + var savedExpanded = new List<int>(expandedOps); + LoadFromAnimationClip(clip, time); + expandedOps = savedExpanded; + expandedOps.RemoveAll(i => i >= operations.Count); + lastAnimTime = time; + ApplyToMaterial(); + Repaint(); + } + void RecordAnimationKeyframes(FoldPipelineBuilder builder) { if (targetObject == null || !AnimationMode.InAnimationMode()) @@ -519,7 +536,10 @@ public class FoldEditorWindow : EditorWindow if (!TryGetAnimationWindowState(out var clip, out float time)) return; float frameDuration = 1f / clip.frameRate; - SetAnimationWindowTime(time + frames * frameDuration); + float newTime = time + frames * frameDuration; + SetAnimationWindowTime(newTime); + lastAnimTime = newTime; // Suppress OnEditorUpdate from reloading animation data. + ApplyToMaterial(); // Re-apply current editor state so the scene stays in sync. Repaint(); } @@ -552,6 +572,8 @@ public class FoldEditorWindow : EditorWindow if (bestDist < float.MaxValue) { SetAnimationWindowTime(bestTime); + lastAnimTime = bestTime; // Suppress OnEditorUpdate from reloading animation data. + ApplyToMaterial(); // Re-apply current editor state so the scene stays in sync. Repaint(); } } |
