- Home /
Undo GUILayout.Window Drag
I have a GUILayout.Window dragging with their rects serialized in objects, but how can I make each drag undoable? I can't seem to find a way to detect the beginning of a drag that is enabled by GUI.DragWindow() as a place to call Undo.RegisterCompleteObjectUndo (model, "Window Drag");. The desired behavior is that there are several windows displayed in my EditorWindow and when any one of them is moved, that move can be undone.
void OnGUI() {
int index = 0;
foreach(MyObject mo in model.myObjects) {
mo.rect = GUILayout.Window(index++, mo.rect, doWindow, "My Window");
}
}
void doWindow(int id)
{
GUI.DragWindow();
}
Your answer
Follow this Question
Related Questions
Can you use a more performant undo function than RegisterSceneUndo with DestroyImmediate? 2 Answers
EventType.ValidateCommand includes Undo? 0 Answers
Undo in Editor only executed when I switch focus to Hierarchy 0 Answers
How to use the Undo class to record editor script property changes? 2 Answers
ObjectField in GUILayout.Window Not Working - Returns None 1 Answer