From 45a1a2ec67cffaea43fdb0953720ef78699220af Mon Sep 17 00:00:00 2001 From: Jordan Wilgus Date: Wed, 8 Feb 2023 19:16:42 -0500 Subject: [PATCH] Add files via upload --- CallEditorModalExample.cs | 14 ++++++++++++++ EditorModal.cs | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 CallEditorModalExample.cs create mode 100644 EditorModal.cs diff --git a/CallEditorModalExample.cs b/CallEditorModalExample.cs new file mode 100644 index 0000000..47ac3f7 --- /dev/null +++ b/CallEditorModalExample.cs @@ -0,0 +1,14 @@ +using EditorModal; +using UnityEditor; + +public class CallEditorModalExample +{ + [MenuItem("Window/Plugins/EditorModal/Open Editor Modal Example")] + [MenuItem("Editor Modal/Open Editor Modal Example")] + private static void OpenEditorModal() + { + EditorPopupModal popupModal = (EditorPopupModal)EditorWindow.GetWindow(typeof(EditorPopupModal), true, "NOTICE", true); + popupModal.ShowModalUtility(); + popupModal.Focus(); + } +} \ No newline at end of file diff --git a/EditorModal.cs b/EditorModal.cs new file mode 100644 index 0000000..657151d --- /dev/null +++ b/EditorModal.cs @@ -0,0 +1,36 @@ +//Author: https://github.com/seekeroftheball + +using UnityEditor; +using UnityEngine; + +namespace EditorModal +{ + public class EditorPopupModal : EditorWindow + { + private struct WindowBounds + { + public const float WindowWidth = 242; + public const float WindowHeight = 72; + + public static Vector2 WindowSize = new(WindowWidth, WindowHeight); + } + + private EditorPopupModal() + { + minSize = WindowBounds.WindowSize; + maxSize = WindowBounds.WindowSize; + } + + private void OnGUI() => DrawWindow(); + + private void OnInspectorUpdate() => Repaint(); + + private void DrawWindow() + { + GUILayout.Label("Here's some text in a pop-up window.\n\nPress Close to dismiss this message.", EditorStyles.wordWrappedLabel); + + if (GUILayout.Button("Close")) + Close(); + } + } +} \ No newline at end of file