Hello, the following code below is working fine 2021.1 branch while on 2021.2b4 it failed at getRecordsInternalDelegate line 18:
public static void EnableUndoPro()
{
enabled = true;
// Assure it is subscribed to all necessary events for undo/redo recognition
Undo.undoRedoPerformed -= UndoRedoPerformed;
Undo.undoRedoPerformed += UndoRedoPerformed;
EditorApplication.update -= Update;
EditorApplication.update += Update;
EditorApplication.playModeStateChanged -= PlaymodeStateChange;
EditorApplication.playModeStateChanged += PlaymodeStateChange;
// Fetch Reflection members for Undo interaction
Assembly UnityEditorAsssembly = Assembly.GetAssembly(typeof(UnityEditor.Editor));
Type undoType = UnityEditorAsssembly.GetType("UnityEditor.Undo");
MethodInfo getRecordsInternal = undoType.GetMethod("GetRecordsInternal", BindingFlags.NonPublic | BindingFlags.Static);
getRecordsInternalDelegate = (Action<object, object>)Delegate.CreateDelegate(typeof(Action<object, object>), getRecordsInternal);
// Create dummy object
if (dummyObject == null)
dummyObject = new Texture2D(8, 8);
// Setup default undo state and record
AssureRecords();
}
Anyone can point me at right direction? is it a bug or plain new C# standard?
The full asset located in here.