51 lines
1.5 KiB
C#
51 lines
1.5 KiB
C#
using Stary.Evo.Editor;
|
||
using UnityEditor;
|
||
using UnityEngine;
|
||
|
||
namespace Stary.Evo
|
||
{
|
||
[CustomEditor(typeof(HybridClREntrance))]
|
||
public class HybridClREntranceEditor : UnityEditor.Editor
|
||
{
|
||
/// <summary>
|
||
/// 序列化属性,在OnEnable中获取
|
||
/// </summary>
|
||
[HideInInspector]
|
||
private SerializedProperty domain;
|
||
|
||
private string[] domainNames;
|
||
private void OnEnable()
|
||
{
|
||
domain = serializedObject.FindProperty("domain");
|
||
domainNames = CreatAssetWindow.GetCreatDomainAllName();
|
||
|
||
}
|
||
|
||
public override void OnInspectorGUI()
|
||
{
|
||
serializedObject.Update();
|
||
|
||
// 获取当前选中的索引
|
||
int selectedIndex = System.Array.IndexOf(domainNames, domain.stringValue);
|
||
if (selectedIndex < 0) selectedIndex = 0; // 默认选中第一个
|
||
|
||
// 绘制下拉选择框
|
||
selectedIndex = EditorGUILayout.Popup("Domain", selectedIndex, domainNames);
|
||
|
||
// 更新选择的域名
|
||
domain.stringValue = domainNames[selectedIndex];
|
||
|
||
serializedObject.ApplyModifiedProperties();
|
||
|
||
HybridClREntrance hybridClREntrance = target as HybridClREntrance;
|
||
if (GUILayout.Button("打开Domain"))
|
||
{
|
||
hybridClREntrance.OpenDomain();
|
||
}
|
||
if (GUILayout.Button("关闭Domain"))
|
||
{
|
||
hybridClREntrance.CloseDomain();
|
||
}
|
||
}
|
||
}
|
||
} |