private void HookIntoUnityEditorUndoSystem()
 {
     Debug.Log("Hooking into UnityEditor.Undo");
     _tracker = ScriptableObject.CreateInstance <UndoRedoTracker>();
     if (_tracker == null)
     {
         throw new NullReferenceException("CreateInstance<UndoRedoTracker>() failed!");
     }
     _oldUndoRedoCallback = UnityEditor.Undo.undoRedoPerformed;
     UnityEditor.Undo.undoRedoPerformed = UndoRedoPerformed;
 }
 private void UnhookFromUnityEditorUndoSystem()
 {
     Debug.Log("Unhooking from UnityEditor.Undo");
     if (_tracker != null)
     {
         UnityEditor.Undo.undoRedoPerformed = _oldUndoRedoCallback;
         _oldUndoRedoCallback = null;
         // FIXME: This doesn't work, lets hope it'll get fixed in the near future.
         UnityEditor.Undo.ClearUndo(_tracker);
         ScriptableObject.DestroyImmediate(_tracker);
         _tracker = null;
     }
     else
     {
         throw new InvalidOperationException("Not hooked into UnityEditor.Undo.");
     }
 }