66 lines
1.9 KiB
C#
66 lines
1.9 KiB
C#
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace UNSDK
|
|
{
|
|
public class ConfigEditor : EditorWindow
|
|
{
|
|
private static ConfigEditor _view;
|
|
|
|
[MenuItem("Tools/CreateConfig")]
|
|
public static void ShowWindow()
|
|
{
|
|
if (_view != null)
|
|
{
|
|
CloseView();
|
|
return;
|
|
}
|
|
_view = GetWindow<ConfigEditor>();
|
|
_view.titleContent = new GUIContent("ConfigEditor");
|
|
}
|
|
|
|
static void CloseView()
|
|
{
|
|
_view.Close();
|
|
_view = null;
|
|
}
|
|
|
|
private void OnGUI()
|
|
{
|
|
DrawWindow();
|
|
EditorUtility.SetDirty(SdkConfigMgr.Instance);
|
|
}
|
|
|
|
private void DrawWindow()
|
|
{
|
|
TextLabel("Sdk 配置",Color.white);
|
|
EditorGUILayout.BeginVertical("frameBox");
|
|
SdkConfigMgr.Instance.secret = EditorGUILayout.TextField("Secret", SdkConfigMgr.Instance.secret);
|
|
SdkConfigMgr.Instance.host = EditorGUILayout.TextField("Host", SdkConfigMgr.Instance.host);
|
|
EditorGUILayout.EndVertical();
|
|
|
|
|
|
TextLabel("Debug Log",Color.white);
|
|
EditorGUILayout.BeginVertical("frameBox");
|
|
SdkConfigMgr.Instance.isLog = EditorGUILayout.Toggle("IsLog", SdkConfigMgr.Instance.isLog);
|
|
EditorGUILayout.EndVertical();
|
|
|
|
|
|
}
|
|
|
|
private void TextLabel(string content, Color color = new Color())
|
|
{
|
|
if (color.Equals(Color.clear))
|
|
{
|
|
color = Color.gray;
|
|
}
|
|
GUIStyle style = new GUIStyle();
|
|
style.contentOffset = new Vector2(8, 0);
|
|
style.normal.textColor = color;
|
|
style.fontSize = 14;
|
|
style.padding = new RectOffset(0, 0, 3, 0);
|
|
GUILayout.Label(content, style);
|
|
}
|
|
}
|
|
}
|