79 lines
2.6 KiB
C#
79 lines
2.6 KiB
C#
using System;
|
||
using Stary.Evo.Editor;
|
||
using UnityEditor;
|
||
using UnityEngine;
|
||
|
||
namespace Stary.Evo
|
||
{
|
||
[InitializeOnLoad]
|
||
public static class CreatDomainDirectory
|
||
{
|
||
static CreatDomainDirectory()
|
||
{
|
||
// 注意 因为这个构造函数会被重复调用,
|
||
//所以为了防止quitting和update两个回调被重复添加,需要先移除后添加
|
||
EditorApplication.quitting -= OnEditorQuit;
|
||
EditorApplication.quitting += OnEditorQuit;
|
||
|
||
Debug.Log(" 自动运行 ");
|
||
|
||
if (!PlayerPrefs.HasKey("StartUp"))
|
||
{
|
||
// 通过标记记录是否已经执行过该方法
|
||
OnEditorStartUp();
|
||
PlayerPrefs.SetInt("StartUp", 1);
|
||
|
||
if (PlayerPrefs.GetInt("CreatDomainDirectory") == 0)
|
||
{
|
||
PlayerPrefs.SetInt("CreatDomainDirectory", 1);
|
||
bool isOk = EditorUtility.DisplayDialog("提示", "发现目录存在缺失,是否检索并创建缺失目录", "是", "否");
|
||
if (isOk)
|
||
{
|
||
var DomainAll = CreatAssetWindow.GetCreatDomainAll();
|
||
foreach (var domain in DomainAll)
|
||
{
|
||
CreatAssetWindow.CreateDomainDirectory(domain.DomainName);
|
||
}
|
||
}
|
||
}
|
||
|
||
if (EditorPrefs.GetString("ChangeHotUpdateSchema") == "")
|
||
{
|
||
ChangeHotUpdateSchema.SetHotUpdateMode(HotUpdateMode.NotUpdate);
|
||
}
|
||
else
|
||
{
|
||
ChangeHotUpdateSchema.SetHotUpdateMode(
|
||
Enum.Parse<HotUpdateMode>(EditorPrefs.GetString("ChangeHotUpdateSchema")));
|
||
}
|
||
|
||
if (EditorPrefs.GetString("ChangePlayerSchema") == "")
|
||
{
|
||
ChangePlayerSchema.SetPlayerMode(PLayerMode.EDITOR_SIMULATEMODE);
|
||
}
|
||
else
|
||
{
|
||
ChangePlayerSchema.SetPlayerMode(
|
||
Enum.Parse<PLayerMode>(EditorPrefs.GetString("ChangePlayerSchema")));
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// UnityEditor 关闭时取消标记
|
||
/// </summary>
|
||
private static void OnEditorQuit()
|
||
{
|
||
PlayerPrefs.DeleteKey("StartUp");
|
||
}
|
||
|
||
/// <summary>
|
||
/// 只会在UnityEditor启动时执行一次
|
||
/// </summary>
|
||
static void OnEditorStartUp()
|
||
{
|
||
Debug.Log(" UnityEditor 启动 ");
|
||
}
|
||
}
|
||
} |