2025-09-04 11:43:35 +08:00
|
|
|
|
using System;
|
2025-05-23 18:26:47 +08:00
|
|
|
|
using Stary.Evo.Editor;
|
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Stary.Evo
|
|
|
|
|
|
{
|
|
|
|
|
|
[CustomEditor(typeof(HybridClREntrance))]
|
|
|
|
|
|
public class HybridClREntranceEditor : UnityEditor.Editor
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 序列化属性,在OnEnable中获取
|
|
|
|
|
|
/// </summary>
|
2025-10-31 11:18:23 +08:00
|
|
|
|
[HideInInspector] private SerializedProperty domain;
|
|
|
|
|
|
|
|
|
|
|
|
private SerializedProperty stage;
|
2025-09-04 11:43:35 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 序列化属性,在OnEnable中获取
|
|
|
|
|
|
/// </summary>
|
2025-10-31 11:18:23 +08:00
|
|
|
|
[HideInInspector] private SerializedProperty loadDomain;
|
|
|
|
|
|
|
2025-05-23 18:26:47 +08:00
|
|
|
|
private string[] domainNames;
|
2025-10-31 11:18:23 +08:00
|
|
|
|
private string[] artNames;
|
2025-09-04 11:43:35 +08:00
|
|
|
|
private string[] loadDomainNames;
|
2025-10-31 11:18:23 +08:00
|
|
|
|
|
|
|
|
|
|
private async void OnEnable()
|
2025-05-23 18:26:47 +08:00
|
|
|
|
{
|
|
|
|
|
|
domain = serializedObject.FindProperty("domain");
|
2025-09-04 11:43:35 +08:00
|
|
|
|
loadDomain = serializedObject.FindProperty("loadDomain");
|
2025-10-31 11:18:23 +08:00
|
|
|
|
stage = serializedObject.FindProperty("stage");
|
2025-05-23 18:26:47 +08:00
|
|
|
|
domainNames = CreatAssetWindow.GetCreatDomainAllName();
|
2025-10-31 11:18:23 +08:00
|
|
|
|
artNames = await ArtLoadAssetServer.GetServerDomainAllName();
|
2025-09-04 11:43:35 +08:00
|
|
|
|
// 创建新数组,长度+1并在第0位插入null
|
|
|
|
|
|
// 创建新数组,长度+1并在第0位插入null
|
|
|
|
|
|
loadDomainNames = new string[domainNames.Length + 1];
|
2025-10-31 11:18:23 +08:00
|
|
|
|
loadDomainNames[0] = "null"; // 第0位添加null
|
2025-09-04 11:43:35 +08:00
|
|
|
|
Array.Copy(domainNames, 0, loadDomainNames, 1, domainNames.Length); // 复制原始元素到新数组从索引1开始
|
2025-05-23 18:26:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnInspectorGUI()
|
|
|
|
|
|
{
|
|
|
|
|
|
serializedObject.Update();
|
2025-10-31 11:18:23 +08:00
|
|
|
|
|
|
|
|
|
|
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];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-05-23 18:26:47 +08:00
|
|
|
|
HybridClREntrance hybridClREntrance = target as HybridClREntrance;
|
|
|
|
|
|
if (GUILayout.Button("打开Domain"))
|
|
|
|
|
|
{
|
|
|
|
|
|
hybridClREntrance.OpenDomain();
|
|
|
|
|
|
}
|
2025-10-31 11:18:23 +08:00
|
|
|
|
|
2025-05-23 18:26:47 +08:00
|
|
|
|
if (GUILayout.Button("关闭Domain"))
|
|
|
|
|
|
{
|
|
|
|
|
|
hybridClREntrance.CloseDomain();
|
|
|
|
|
|
}
|
2025-10-31 11:18:23 +08:00
|
|
|
|
|
2025-09-04 11:43:35 +08:00
|
|
|
|
//loaddoamin绘制
|
|
|
|
|
|
// 获取当前选中的索引
|
2025-10-31 11:18:23 +08:00
|
|
|
|
|
|
|
|
|
|
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];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-04 11:43:35 +08:00
|
|
|
|
serializedObject.ApplyModifiedProperties();
|
2025-05-23 18:26:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|