2025-07-02 16:28:08 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using Stary.Evo.Editor;
|
2025-04-16 18:20:46 +08:00
|
|
|
|
using UnityEditor;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Stary.Evo
|
|
|
|
|
|
{
|
|
|
|
|
|
[InitializeOnLoad]
|
|
|
|
|
|
public static class CreatDomainDirectory
|
|
|
|
|
|
{
|
|
|
|
|
|
static CreatDomainDirectory()
|
|
|
|
|
|
{
|
2025-07-02 16:28:08 +08:00
|
|
|
|
// 注意 因为这个构造函数会被重复调用,
|
|
|
|
|
|
//所以为了防止quitting和update两个回调被重复添加,需要先移除后添加
|
|
|
|
|
|
EditorApplication.quitting -= OnEditorQuit;
|
|
|
|
|
|
EditorApplication.quitting += OnEditorQuit;
|
2026-03-25 16:58:26 +08:00
|
|
|
|
|
2025-07-02 16:28:08 +08:00
|
|
|
|
|
2026-01-07 18:20:13 +08:00
|
|
|
|
if (!CustomEditorPrefs.HasKey("StartUp"))
|
2025-04-16 18:20:46 +08:00
|
|
|
|
{
|
2025-07-02 16:28:08 +08:00
|
|
|
|
// 通过标记记录是否已经执行过该方法
|
|
|
|
|
|
OnEditorStartUp();
|
2026-01-07 18:20:13 +08:00
|
|
|
|
CustomEditorPrefs.SetInt("StartUp", 1);
|
2025-07-02 16:28:08 +08:00
|
|
|
|
|
2026-01-07 18:20:13 +08:00
|
|
|
|
if (CustomEditorPrefs.GetInt("CreatDomainDirectory") == 0)
|
2025-04-16 18:20:46 +08:00
|
|
|
|
{
|
2026-01-07 18:20:13 +08:00
|
|
|
|
CustomEditorPrefs.SetInt("CreatDomainDirectory", 1);
|
2025-07-02 16:28:08 +08:00
|
|
|
|
bool isOk = EditorUtility.DisplayDialog("提示", "发现目录存在缺失,是否检索并创建缺失目录", "是", "否");
|
|
|
|
|
|
if (isOk)
|
2025-04-16 18:20:46 +08:00
|
|
|
|
{
|
2025-07-02 16:28:08 +08:00
|
|
|
|
var DomainAll = CreatAssetWindow.GetCreatDomainAll();
|
|
|
|
|
|
foreach (var domain in DomainAll)
|
|
|
|
|
|
{
|
|
|
|
|
|
CreatAssetWindow.CreateDomainDirectory(domain.DomainName);
|
|
|
|
|
|
}
|
2025-04-16 18:20:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-07-02 16:28:08 +08:00
|
|
|
|
|
2026-01-07 18:20:13 +08:00
|
|
|
|
if (CustomEditorPrefs.GetString("ChangePlayerSchema") == "")
|
2025-07-02 16:28:08 +08:00
|
|
|
|
{
|
|
|
|
|
|
ChangePlayerSchema.SetPlayerMode(PLayerMode.EDITOR_SIMULATEMODE);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
ChangePlayerSchema.SetPlayerMode(
|
2026-04-13 21:24:12 +08:00
|
|
|
|
Enum.Parse<PLayerMode>(CustomEditorPrefs.GetString("ChangePlayerSchema")));
|
2025-07-02 16:28:08 +08:00
|
|
|
|
}
|
2025-04-16 18:20:46 +08:00
|
|
|
|
}
|
2025-07-02 16:28:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// UnityEditor 关闭时取消标记
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private static void OnEditorQuit()
|
|
|
|
|
|
{
|
2026-04-13 21:24:12 +08:00
|
|
|
|
CustomEditorPrefs.DeleteKey("StartUp");
|
2025-07-02 16:28:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 只会在UnityEditor启动时执行一次
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
static void OnEditorStartUp()
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.Log(" UnityEditor 启动 ");
|
|
|
|
|
|
}
|
2025-04-16 18:20:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|