From a1681079370014430529d49807cae6c84fa6fa36 Mon Sep 17 00:00:00 2001 From: piti6 Date: Fri, 19 Feb 2021 22:31:17 +0900 Subject: [PATCH 1/2] Fix undo was not working --- Scripts/InternalBridge/Data/CachedSkin.cs | 1 + .../SkinEditorWindow/SkinEditorWindow.cs | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Scripts/InternalBridge/Data/CachedSkin.cs b/Scripts/InternalBridge/Data/CachedSkin.cs index 2bfbda0..90644cb 100644 --- a/Scripts/InternalBridge/Data/CachedSkin.cs +++ b/Scripts/InternalBridge/Data/CachedSkin.cs @@ -34,6 +34,7 @@ public static bool Update(Skin skin) else { instance._skin = skin; + EditorUtility.SetDirty(instance); _dirty = true; return true; diff --git a/Scripts/InternalBridge/SkinEditorWindow/SkinEditorWindow.cs b/Scripts/InternalBridge/SkinEditorWindow/SkinEditorWindow.cs index f87935d..f5bc8a3 100644 --- a/Scripts/InternalBridge/SkinEditorWindow/SkinEditorWindow.cs +++ b/Scripts/InternalBridge/SkinEditorWindow/SkinEditorWindow.cs @@ -42,7 +42,7 @@ private void OnEnable() { UpdateCurrentSkin(CachedSkin.Skin); - Undo.selectionUndoRedoPerformed += UndoRedoPerformed; + Undo.undoRedoPerformed += UndoRedoPerformed ; _inspectedViewChunk.OnViewChanged += OnViewChanged; _skinMenuView.OnChangeName += OnChangeName; @@ -235,7 +235,7 @@ private void UpdateCachedSkin(bool recordUndo) { if (recordUndo) { - Undo.RecordObject(CachedSkin.instance, "CachedSkin"); + Undo.RegisterCreatedObjectUndo(CachedSkin.instance, "CachedSkin"); } CachedSkin.Update(_currentSkin.ToImmutable(grantNewId: false)); @@ -298,11 +298,13 @@ private void OnSelectInspectionValue(object userdata, string[] options, int sele _inspectedViewChunk.ChangeInspectionValue(selected >= 0 ? selectableViews[selected] : null); } - private void UndoRedoPerformed(Undo.UndoRedoType obj) + private void UndoRedoPerformed() { UpdateCurrentSkin(CachedSkin.Skin); Repaint(); + + _inspectedViewChunk.InspectedView.Repaint(); } private void UpdateCurrentSkin(Skin targetSkin) @@ -347,7 +349,7 @@ private void OnDisable() { _highlighter.ClearHighlighters(); - Undo.selectionUndoRedoPerformed -= UndoRedoPerformed; + Undo.undoRedoPerformed -= UndoRedoPerformed; _inspectedViewChunk.OnViewChanged -= OnViewChanged; _skinMenuView.OnChangeName -= OnChangeName; From 8c2dee8330d36d4dd290fafa0bf5e27573459432 Mon Sep 17 00:00:00 2001 From: piti6 Date: Fri, 19 Feb 2021 22:32:15 +0900 Subject: [PATCH 2/2] Tweak --- Scripts/InternalBridge/SkinEditorWindow/SkinEditorWindow.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/InternalBridge/SkinEditorWindow/SkinEditorWindow.cs b/Scripts/InternalBridge/SkinEditorWindow/SkinEditorWindow.cs index f5bc8a3..2d15823 100644 --- a/Scripts/InternalBridge/SkinEditorWindow/SkinEditorWindow.cs +++ b/Scripts/InternalBridge/SkinEditorWindow/SkinEditorWindow.cs @@ -42,7 +42,7 @@ private void OnEnable() { UpdateCurrentSkin(CachedSkin.Skin); - Undo.undoRedoPerformed += UndoRedoPerformed ; + Undo.undoRedoPerformed += UndoRedoPerformed; _inspectedViewChunk.OnViewChanged += OnViewChanged; _skinMenuView.OnChangeName += OnChangeName;