-
-
Save anchan828/2b26686384901b228897 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEngine; | |
public class Question10_practical : EditorWindow | |
{ | |
[MenuItem("Window/Question10_practical")] | |
private static void Open() | |
{ | |
GetWindow<Question10_practical>(); | |
} | |
private Question10_RectData_practical rectData; | |
void OnEnable() | |
{ | |
rectData = CreateInstance<Question10_RectData_practical>(); | |
} | |
void OnGUI() | |
{ | |
if (Event.current.commandName == "UndoRedoPerformed") | |
{ | |
Repaint(); | |
Focus(); | |
} | |
BeginWindows(); | |
rectData.windowRect = GUI.Window(0, rectData.windowRect, (windowID) => | |
{ | |
Undo.SetSnapshotTarget(rectData, "Moved Window"); | |
if (Event.current.type == EventType.MouseDown) | |
{ | |
Undo.CreateSnapshot(); | |
Undo.RegisterSnapshot(); | |
} | |
GUI.DragWindow(); | |
}, ""); | |
EndWindows(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class Question10_RectData_practical : ScriptableObject | |
{ | |
public Rect windowRect = new Rect(0, 0, 100, 100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment