This commit is contained in:
zhangzheng
2026-03-25 16:58:26 +08:00
parent 3a9813675e
commit 2c230960db
22 changed files with 517 additions and 232 deletions

View File

@@ -0,0 +1,76 @@
using System;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace Stary.Evo.Editor
{
public class ChangeDeviceMode
{
public static DeviceMode DeviceMode
{
get => _deviceMode;
set => SetDeviceMode(value);
}
private static DeviceMode _deviceMode;
private const string EditorRokidMode = "Evo/Schema/ChangeDevice/Rokid";
private const string EditorXrealMode = "Evo/Schema/ChangeDevice/Xreal";
[MenuItem(EditorRokidMode)]
private static void SetRokidMode() => SetDeviceMode(DeviceMode.Evo_Rokid);
[MenuItem(EditorXrealMode)]
private static void SetXrealMode() => SetDeviceMode(DeviceMode.Evo_Xreal);
// [MenuItem(WebPlayMode)]
// private static void SetWebMode() => SetPlayerMode(HotUpdateMode.WEB_PLAYMODE);
[MenuItem(EditorRokidMode, true)]
private static bool ValidateModeMenu()
{
string platform = CustomEditorPrefs.GetString("ChangeDeviceSchema");
Menu.SetChecked(EditorRokidMode, platform == DeviceMode.Evo_Rokid.ToString());
Menu.SetChecked(EditorXrealMode, platform == DeviceMode.Evo_Xreal.ToString());
//Menu.SetChecked(WebPlayMode, platform == HotUpdateMode.WEB_PLAYMODE.ToString());
Debug.Log($"ChangeDeviceSchema:{platform}");
return true;
}
public static void SetDeviceMode(DeviceMode mode)
{
// 清除所有旧模式定义
var currentTarget = EditorUserBuildSettings.selectedBuildTargetGroup;
if (currentTarget == BuildTargetGroup.Unknown) return;
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(currentTarget)
.Split(';')
.Where(d => !Enum.GetNames(typeof(DeviceMode)).Contains(d))
.ToList();
// 添加新模式
defines.Add(mode.ToString());
PlayerSettings.SetScriptingDefineSymbolsForGroup(currentTarget, string.Join(";", defines));
_deviceMode = mode;
CustomEditorPrefs.SetString("ChangeDeviceSchema", _deviceMode.ToString());
ValidateModeMenu();
AssetDatabase.Refresh();
// 添加解决方案文件重新生成逻辑
EditorApplication.delayCall += () =>
{
UnityEditor.Compilation.CompilationPipeline.RequestScriptCompilation();
Debug.Log($"当前编译符号: {string.Join(";", defines)}"); // 添加调试日志
};
}
}
public enum DeviceMode
{
//Xreal,
Evo_Xreal,
//Rokid,
Evo_Rokid,
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b531f86493d647afbf2f37c523e62bcb
timeCreated: 1774426824

View File

@@ -34,7 +34,7 @@ namespace Stary.Evo.Editor
Menu.SetChecked(EditorNotUpdateMode, platform == HotUpdateMode.NotUpdate.ToString());
Menu.SetChecked(EditorHotUpdateMode, platform == HotUpdateMode.HotUpdate.ToString());
//Menu.SetChecked(WebPlayMode, platform == HotUpdateMode.WEB_PLAYMODE.ToString());
Debug.LogError("ChangeHotUpdateSchema:"+platform);
Debug.Log("ChangeHotUpdateSchema:"+platform);
return true;
}

View File

@@ -37,7 +37,7 @@ namespace Stary.Evo.Editor
Menu.SetChecked(HostPlayMode, platform == PLayerMode.HOST_PLAYMODE.ToString());
Menu.SetChecked(LocalPlayMode, platform == PLayerMode.LOCAL_PLAYMODE.ToString());
//Menu.SetChecked(WebPlayMode, platform == PLayerMode.WEB_PLAYMODE.ToString());
Debug.LogError($"ChangePlayerSchema:{platform}");
Debug.Log($"ChangePlayerSchema:{platform}");
return true;
}

View File

@@ -34,7 +34,7 @@ namespace Stary.Evo.Editor
Menu.SetChecked(EditorNotMode, platform == PointClondMode.NotPointClond.ToString());
Menu.SetChecked(EditorImmersalMode, platform == PointClondMode.Immersal.ToString());
//Menu.SetChecked(WebPlayMode, platform == HotUpdateMode.WEB_PLAYMODE.ToString());
Debug.LogError("ChangePoindClondSchema");
Debug.Log($"ChangePoindClondSchema:{platform}");
return true;
}

View File

@@ -14,8 +14,7 @@ namespace Stary.Evo
//所以为了防止quitting和update两个回调被重复添加需要先移除后添加
EditorApplication.quitting -= OnEditorQuit;
EditorApplication.quitting += OnEditorQuit;
Debug.Log(" 自动运行 ");
if (!CustomEditorPrefs.HasKey("StartUp"))
{