-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a914b03
commit 3c2bf30
Showing
5 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using UnityEditor; | ||
using UnityEditor.Presets; | ||
|
||
namespace ArtNet.Editor.DmxRecorder | ||
{ | ||
public class PresetRecorder : PresetSelectorReceiver | ||
{ | ||
private RecorderSettings _target; | ||
private Preset _initialValue; | ||
private Action _onSelectionChanged; | ||
private Action _onSelectionClosed; | ||
|
||
internal void Init(RecorderSettings target, Action onSelectionChanged = null, Action onSelectionClosed = null) | ||
{ | ||
_onSelectionChanged = onSelectionChanged; | ||
_onSelectionClosed = onSelectionClosed; | ||
_target = target; | ||
_initialValue = new Preset(target); | ||
} | ||
|
||
public override void OnSelectionChanged(Preset selection) | ||
{ | ||
if (selection != null) | ||
{ | ||
Undo.RecordObject(_target, "Apply Preset " + selection.name); | ||
selection.ApplyTo(_target); | ||
} | ||
else | ||
{ | ||
Undo.RecordObject(_target, "Cancel Preset"); | ||
_initialValue.ApplyTo(_target); | ||
} | ||
|
||
_onSelectionChanged?.Invoke(); | ||
} | ||
|
||
public override void OnSelectionClosed(Preset selection) | ||
{ | ||
OnSelectionChanged(selection); | ||
|
||
_target.OnAfterDuplicate(); | ||
_onSelectionClosed?.Invoke(); | ||
|
||
DestroyImmediate(this); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters