From e7e681b82b9f5bd492d3975560d4939c5b03be32 Mon Sep 17 00:00:00 2001 From: yum Date: Tue, 17 Feb 2026 20:47:23 -0800 Subject: Fold: more animation bugfixes --- Scripts/Fold/Editor/FoldEditorWindow.cs | 38 ++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'Scripts/Fold') 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(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(); } } -- cgit v1.2.3