Skip to content

Commit

Permalink
Merge pull request #3 from piti6/mkim/fix-undo
Browse files Browse the repository at this point in the history
Fix undo was not working
  • Loading branch information
piti6 authored Feb 19, 2021
2 parents 418e7f2 + 8c2dee8 commit 4279d47
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions Scripts/InternalBridge/Data/CachedSkin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public static bool Update(Skin skin)
else
{
instance._skin = skin;
EditorUtility.SetDirty(instance);
_dirty = true;

return true;
Expand Down
10 changes: 6 additions & 4 deletions Scripts/InternalBridge/SkinEditorWindow/SkinEditorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private void OnEnable()
{
UpdateCurrentSkin(CachedSkin.Skin);

Undo.selectionUndoRedoPerformed += UndoRedoPerformed;
Undo.undoRedoPerformed += UndoRedoPerformed;
_inspectedViewChunk.OnViewChanged += OnViewChanged;

_skinMenuView.OnChangeName += OnChangeName;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -347,7 +349,7 @@ private void OnDisable()
{
_highlighter.ClearHighlighters();

Undo.selectionUndoRedoPerformed -= UndoRedoPerformed;
Undo.undoRedoPerformed -= UndoRedoPerformed;
_inspectedViewChunk.OnViewChanged -= OnViewChanged;

_skinMenuView.OnChangeName -= OnChangeName;
Expand Down

0 comments on commit 4279d47

Please sign in to comment.