using System; using UnityEngine; using UnityEditor; namespace BFEditor { public class AddAccountWindow : EditorWindow { static Action onClickAdd; string accountJson; static AddAccountWindow window; AddAccountWindow() { this.titleContent = new GUIContent("添加账号"); } void OnGUI() { GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Space(20); var style = new GUIStyle(GUI.skin.textField); style.wordWrap = true; accountJson = GUILayout.TextField(accountJson, style, GUILayout.Width(400), GUILayout.Height(150)); GUILayout.EndHorizontal(); GUILayout.Space(20); if (GUILayout.Button("导入")) { if (onClickAdd != null) { onClickAdd(accountJson); } } } public static void OpenWindow(Action action) { var rect = new Rect(Screen.width / 2, Screen.height / 2, 450, 245); window = (AddAccountWindow)EditorWindow.GetWindowWithRect(typeof(AddAccountWindow), rect); window.Show(); onClickAdd = action; } public static void CloseWindow() { if (window != null) { window.Close(); } } } }