Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
seekeroftheball authored Feb 9, 2023
1 parent 761b435 commit 45a1a2e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
14 changes: 14 additions & 0 deletions CallEditorModalExample.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
36 changes: 36 additions & 0 deletions EditorModal.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
}

0 comments on commit 45a1a2e

Please sign in to comment.