【m】框架大更新
This commit is contained in:
@@ -11,67 +11,84 @@ namespace Stary.Evo
|
||||
/// <summary>
|
||||
/// 序列化属性,在OnEnable中获取
|
||||
/// </summary>
|
||||
[HideInInspector]
|
||||
private SerializedProperty domain;
|
||||
[HideInInspector] private SerializedProperty domain;
|
||||
|
||||
private SerializedProperty stage;
|
||||
|
||||
/// <summary>
|
||||
/// 序列化属性,在OnEnable中获取
|
||||
/// </summary>
|
||||
[HideInInspector]
|
||||
private SerializedProperty loadDomain;
|
||||
[HideInInspector] private SerializedProperty loadDomain;
|
||||
|
||||
private string[] domainNames;
|
||||
|
||||
private string[] artNames;
|
||||
private string[] loadDomainNames;
|
||||
private void OnEnable()
|
||||
|
||||
private async void OnEnable()
|
||||
{
|
||||
domain = serializedObject.FindProperty("domain");
|
||||
loadDomain = serializedObject.FindProperty("loadDomain");
|
||||
stage = serializedObject.FindProperty("stage");
|
||||
domainNames = CreatAssetWindow.GetCreatDomainAllName();
|
||||
|
||||
artNames = await ArtLoadAssetServer.GetServerDomainAllName();
|
||||
// 创建新数组,长度+1并在第0位插入null
|
||||
// 创建新数组,长度+1并在第0位插入null
|
||||
loadDomainNames = new string[domainNames.Length + 1];
|
||||
loadDomainNames[0]="null"; // 第0位添加null
|
||||
loadDomainNames[0] = "null"; // 第0位添加null
|
||||
Array.Copy(domainNames, 0, loadDomainNames, 1, domainNames.Length); // 复制原始元素到新数组从索引1开始
|
||||
}
|
||||
|
||||
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];
|
||||
|
||||
|
||||
EditorGUILayout.PropertyField(stage, new GUIContent("Stage"));
|
||||
// 在 HybridClREntranceEditor 类的 OnInspectorGUI 方法中
|
||||
StageType currentStage = (StageType)stage.enumValueIndex;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
string[] current = currentStage == StageType.Developer ? domainNames : artNames;
|
||||
|
||||
if (current != null && current.Length > 0)
|
||||
{
|
||||
// 获取当前选中的索引
|
||||
int selectedIndex = System.Array.IndexOf(current, domain.stringValue);
|
||||
if (selectedIndex < 0) selectedIndex = 0; // 默认选中第一个
|
||||
|
||||
// 绘制下拉选择框
|
||||
selectedIndex = EditorGUILayout.Popup("Domain", selectedIndex, current);
|
||||
|
||||
// 更新选择的域名
|
||||
domain.stringValue = current[selectedIndex];
|
||||
}
|
||||
|
||||
|
||||
HybridClREntrance hybridClREntrance = target as HybridClREntrance;
|
||||
if (GUILayout.Button("打开Domain"))
|
||||
{
|
||||
hybridClREntrance.OpenDomain();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("关闭Domain"))
|
||||
{
|
||||
hybridClREntrance.CloseDomain();
|
||||
}
|
||||
|
||||
|
||||
//loaddoamin绘制
|
||||
// 获取当前选中的索引
|
||||
|
||||
|
||||
int loadDomainSelectedIndex = System.Array.IndexOf(loadDomainNames, loadDomain.stringValue);
|
||||
if (loadDomainSelectedIndex < 0) loadDomainSelectedIndex = 0; // 默认选中第一个
|
||||
|
||||
// 绘制下拉选择框
|
||||
loadDomainSelectedIndex = EditorGUILayout.Popup("LoadDomain", loadDomainSelectedIndex, loadDomainNames);
|
||||
|
||||
// 更新选择的域名
|
||||
loadDomain.stringValue = loadDomainNames[loadDomainSelectedIndex];
|
||||
|
||||
|
||||
if (currentStage == StageType.Developer)
|
||||
{
|
||||
int loadDomainSelectedIndex = System.Array.IndexOf(loadDomainNames, loadDomain.stringValue);
|
||||
if (loadDomainSelectedIndex < 0) loadDomainSelectedIndex = 0; // 默认选中第一个
|
||||
|
||||
// 绘制下拉选择框
|
||||
loadDomainSelectedIndex = EditorGUILayout.Popup("LoadDomain", loadDomainSelectedIndex, loadDomainNames);
|
||||
|
||||
// 更新选择的域名
|
||||
loadDomain.stringValue = loadDomainNames[loadDomainSelectedIndex];
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user