IUndoSystem.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using UnityEngine;
  2. namespace UnityEditor.U2D.Sprites
  3. {
  4. internal interface IUndoSystem
  5. {
  6. void RegisterUndoCallback(Undo.UndoRedoCallback undoCallback);
  7. void UnregisterUndoCallback(Undo.UndoRedoCallback undoCallback);
  8. void RegisterCompleteObjectUndo(ScriptableObject obj, string undoText);
  9. void ClearUndo(ScriptableObject obj);
  10. }
  11. internal class UndoSystem : IUndoSystem
  12. {
  13. public void RegisterUndoCallback(Undo.UndoRedoCallback undoCallback)
  14. {
  15. Undo.undoRedoPerformed += undoCallback;
  16. }
  17. public void UnregisterUndoCallback(Undo.UndoRedoCallback undoCallback)
  18. {
  19. Undo.undoRedoPerformed -= undoCallback;
  20. }
  21. public void RegisterCompleteObjectUndo(ScriptableObject so, string undoText)
  22. {
  23. if (so != null)
  24. {
  25. Undo.RegisterCompleteObjectUndo(so, undoText);
  26. }
  27. }
  28. public void ClearUndo(ScriptableObject so)
  29. {
  30. if (so != null)
  31. {
  32. Undo.ClearUndo(so);
  33. }
  34. }
  35. }
  36. }