50 lines
1.2 KiB
C#
50 lines
1.2 KiB
C#
|
using Sirenix.Utilities;
|
||
|
using Sirenix.Utilities.Editor;
|
||
|
using System;
|
||
|
using UnityEditor;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class CustomPopUpWindow : EditorWindow
|
||
|
{
|
||
|
private string _content;
|
||
|
private Action _onAgree;
|
||
|
private Action _onDisagree;
|
||
|
|
||
|
public static void PopUp(string content, Action onAgree = null, Action onDisagree = null)
|
||
|
{
|
||
|
CustomPopUpWindow window = ScriptableObject.CreateInstance<CustomPopUpWindow>();
|
||
|
window._content = content;
|
||
|
window._onAgree = onAgree;
|
||
|
window._onDisagree = onDisagree;
|
||
|
|
||
|
window.position = GUIHelper.GetEditorWindowRect().AlignCenter(220, 100);
|
||
|
window.ShowPopup();
|
||
|
}
|
||
|
|
||
|
|
||
|
void OnGUI()
|
||
|
{
|
||
|
GUILayout.Space(10);
|
||
|
|
||
|
EditorGUILayout.LabelField(_content, EditorStyles.wordWrappedLabel);
|
||
|
|
||
|
GUILayout.FlexibleSpace();
|
||
|
|
||
|
GUILayout.BeginHorizontal();
|
||
|
|
||
|
if (GUILayout.Button("Yes!"))
|
||
|
{
|
||
|
_onAgree?.Invoke();
|
||
|
this.Close();
|
||
|
}
|
||
|
|
||
|
if (GUILayout.Button("No!"))
|
||
|
{
|
||
|
_onDisagree?.Invoke();
|
||
|
this.Close();
|
||
|
}
|
||
|
|
||
|
GUILayout.EndHorizontal();
|
||
|
GUILayout.Space(10);
|
||
|
}
|
||
|
}
|