Files
daluandou/.codely.packages/cn.tuanjie.codely.bridge@1.0.85-47f31100/Editor/Common/EditorProcessGuard.cs
T
huadexuan 13d0c80335 ```
chore(bridge): 删除桥接包的提交记录和Git属性配置

删除了 .codely-bridge-commit 文件中存储的提交哈希值
移除了 .gitattributes 文件中的行结束符配置规则
```
2026-09-24 21:41:14 +08:00

59 lines
2.0 KiB
C#

using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering;
namespace UnityTcp.Editor.Helpers
{
/// <summary>Restricts editor auto-start hooks to the main Editor process.</summary>
public static class EditorProcessGuard
{
public static bool ShouldSkipEditorAutoStart()
=> ShouldSkipEditorAutoStart(IsAssetImportWorkerProcess(), IsSecondaryEditorProcess());
public static bool ShouldSkipEditorUiAutoStart()
=> ShouldSkipEditorUiAutoStart(
IsAssetImportWorkerProcess(),
IsSecondaryEditorProcess(),
Application.isBatchMode,
SystemInfo.graphicsDeviceType == GraphicsDeviceType.Null);
internal static bool ShouldSkipEditorAutoStart(
bool isAssetImportWorker,
bool isSecondaryEditor)
=> isAssetImportWorker || isSecondaryEditor;
internal static bool ShouldSkipEditorUiAutoStart(
bool isAssetImportWorker,
bool isSecondaryEditor,
bool isBatchMode,
bool isNullGraphics)
=> ShouldSkipEditorAutoStart(isAssetImportWorker, isSecondaryEditor)
|| isBatchMode
|| isNullGraphics;
private static bool IsAssetImportWorkerProcess()
{
#if UNITY_2020_2_OR_NEWER
return AssetDatabase.IsAssetImportWorkerProcess();
#elif UNITY_2019_3_OR_NEWER
return UnityEditor.Experimental.AssetDatabaseExperimental.IsAssetImportWorkerProcess();
#else
return false;
#endif
}
private static bool IsSecondaryEditorProcess()
{
#if UNITY_2021_1_OR_NEWER
return UnityEditor.MPE.ProcessService.level == UnityEditor.MPE.ProcessLevel.Secondary;
#elif UNITY_2020_2_OR_NEWER
return UnityEditor.MPE.ProcessService.level == UnityEditor.MPE.ProcessLevel.Slave;
#elif UNITY_2020_1_OR_NEWER
return Unity.MPE.ProcessService.level == Unity.MPE.ProcessLevel.UMP_SLAVE;
#else
return false;
#endif
}
}
}