testss
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.U2D.Animation
|
||||
{
|
||||
internal class DisableUndoScope : IDisposable
|
||||
{
|
||||
private bool m_Disposed;
|
||||
private ICacheUndo m_CacheUndo;
|
||||
private IUndo m_UndoOverride;
|
||||
|
||||
public DisableUndoScope(ICacheUndo cacheUndo)
|
||||
{
|
||||
Debug.Assert(cacheUndo != null);
|
||||
|
||||
m_CacheUndo = cacheUndo;
|
||||
m_UndoOverride = m_CacheUndo.undoOverride;
|
||||
m_CacheUndo.undoOverride = new DisabledUndo();
|
||||
}
|
||||
|
||||
~DisableUndoScope()
|
||||
{
|
||||
if (!m_Disposed)
|
||||
Debug.LogError("Scope was not disposed! You should use the 'using' keyword or manually call Dispose.");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (m_Disposed)
|
||||
return;
|
||||
|
||||
m_Disposed = true;
|
||||
|
||||
if (m_CacheUndo != null)
|
||||
m_CacheUndo.undoOverride = m_UndoOverride;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.U2D.Animation
|
||||
{
|
||||
internal class DisabledUndo : IUndo
|
||||
{
|
||||
public void RecordObject(object o, string name) {}
|
||||
public void RegisterCompleteObjectUndo(object o, string name) {}
|
||||
public void RegisterCompleteObjectUndo(object[] o, string name) {}
|
||||
public void RegisterCreatedObjectUndo(object o, string name) {}
|
||||
public void DestroyObjectImmediate(object o)
|
||||
{
|
||||
BaseObject.DestroyImmediate(o);
|
||||
}
|
||||
|
||||
public void ClearUndo(object o) {}
|
||||
public void IncrementCurrentGroup() {}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
namespace UnityEditor.U2D.Animation
|
||||
{
|
||||
internal interface ICacheUndo
|
||||
{
|
||||
IUndo undoOverride { get; set; }
|
||||
bool isUndoOperationSet { get; }
|
||||
void IncrementCurrentGroup();
|
||||
void BeginUndoOperation(string name);
|
||||
void EndUndoOperation();
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
namespace UnityEditor.U2D.Animation
|
||||
{
|
||||
internal interface IUndo
|
||||
{
|
||||
void RecordObject(object o, string name);
|
||||
void RegisterCompleteObjectUndo(object o, string name);
|
||||
void RegisterCompleteObjectUndo(object[] o, string name);
|
||||
void RegisterCreatedObjectUndo(object o, string name);
|
||||
void DestroyObjectImmediate(object o);
|
||||
void ClearUndo(object o);
|
||||
void IncrementCurrentGroup();
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.U2D.Animation
|
||||
{
|
||||
internal class UndoScope : IDisposable
|
||||
{
|
||||
private bool m_Disposed;
|
||||
private ICacheUndo m_CacheUndo;
|
||||
|
||||
public UndoScope(ICacheUndo cacheUndo, string operationName, bool incrementGroup)
|
||||
{
|
||||
Debug.Assert(cacheUndo != null);
|
||||
|
||||
if(cacheUndo.isUndoOperationSet == false)
|
||||
{
|
||||
m_CacheUndo = cacheUndo;
|
||||
|
||||
if(incrementGroup)
|
||||
m_CacheUndo.IncrementCurrentGroup();
|
||||
|
||||
m_CacheUndo.BeginUndoOperation(operationName);
|
||||
}
|
||||
}
|
||||
|
||||
~UndoScope()
|
||||
{
|
||||
if (!m_Disposed)
|
||||
Debug.LogError("Scope was not disposed! You should use the 'using' keyword or manually call Dispose.");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (m_Disposed)
|
||||
return;
|
||||
|
||||
m_Disposed = true;
|
||||
|
||||
if (m_CacheUndo != null)
|
||||
m_CacheUndo.EndUndoOperation();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace UnityEditor.U2D.Animation
|
||||
{
|
||||
internal class UnityEngineUndo : IUndo
|
||||
{
|
||||
public void RecordObject(object o, string name)
|
||||
{
|
||||
var obj = o as Object;
|
||||
if (obj != null)
|
||||
Undo.RecordObject(obj, name);
|
||||
}
|
||||
|
||||
public void RegisterCompleteObjectUndo(object o, string name)
|
||||
{
|
||||
var obj = o as Object;
|
||||
if (obj != null)
|
||||
Undo.RegisterCompleteObjectUndo(obj, name);
|
||||
}
|
||||
|
||||
public void RegisterCompleteObjectUndo(object[] o, string name)
|
||||
{
|
||||
var obj = o as Object[];
|
||||
if (obj != null)
|
||||
Undo.RegisterCompleteObjectUndo(obj, name);
|
||||
}
|
||||
|
||||
public void RegisterCreatedObjectUndo(object o, string name)
|
||||
{
|
||||
var obj = o as Object;
|
||||
if (obj != null)
|
||||
Undo.RegisterCreatedObjectUndo(obj, name);
|
||||
}
|
||||
|
||||
public void DestroyObjectImmediate(object o)
|
||||
{
|
||||
var obj = o as Object;
|
||||
if (obj != null)
|
||||
Undo.DestroyObjectImmediate(obj);
|
||||
}
|
||||
|
||||
public void ClearUndo(object o)
|
||||
{
|
||||
var obj = o as Object;
|
||||
if (obj != null)
|
||||
Undo.ClearUndo(obj);
|
||||
}
|
||||
|
||||
public void IncrementCurrentGroup()
|
||||
{
|
||||
Undo.IncrementCurrentGroup();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user