[refactor] 调整HybridCLR.Editor模块一些不规范的命名空间

main
walon 2023-10-09 15:39:32 +08:00
parent a77ed7369a
commit 69de3d733d
13 changed files with 81 additions and 62 deletions

View File

@ -6,13 +6,14 @@ using System.Linq;
using System.Text; using System.Text;
using UnityEditor; using UnityEditor;
using System.Reflection; using System.Reflection;
using HybridCLR.Editor.Settings;
#if (UNITY_2020 || UNITY_2021) && UNITY_IOS #if (UNITY_2020 || UNITY_2021) && UNITY_IOS
using UnityEditor.Build; using UnityEditor.Build;
using UnityEditor.Callbacks; using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode; using UnityEditor.iOS.Xcode;
using UnityEngine; using UnityEngine;
namespace HybridCLR.Editor namespace HybridCLR.Editor.BuildProcessors
{ {
public static class AddLil2cppSourceCodeToXcodeproj2021OrOlder public static class AddLil2cppSourceCodeToXcodeproj2021OrOlder
{ {

View File

@ -8,7 +8,7 @@ using UnityEngine;
#if UNITY_2022_2_OR_NEWER && UNITY_IOS #if UNITY_2022_2_OR_NEWER && UNITY_IOS
namespace HybridCLR.Editor namespace HybridCLR.Editor.BuildProcessors
{ {
public static class AddLil2cppSourceCodeToXcodeproj2022OrNewer public static class AddLil2cppSourceCodeToXcodeproj2022OrNewer
{ {

View File

@ -1,4 +1,5 @@
using System; using HybridCLR.Editor.Settings;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;

View File

@ -3,24 +3,28 @@ using System;
using UnityEditor.Build; using UnityEditor.Build;
using UnityEditor.Build.Reporting; using UnityEditor.Build.Reporting;
public class MsvcStdextWorkaround : IPreprocessBuildWithReport namespace HybridCLR.Editor.BuildProcessors
{ {
const string kWorkaroundFlag = "/D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS";
public int callbackOrder => 0; public class MsvcStdextWorkaround : IPreprocessBuildWithReport
public void OnPreprocessBuild(BuildReport report)
{ {
var clEnv = Environment.GetEnvironmentVariable("_CL_"); const string kWorkaroundFlag = "/D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS";
if (string.IsNullOrEmpty(clEnv)) public int callbackOrder => 0;
public void OnPreprocessBuild(BuildReport report)
{ {
Environment.SetEnvironmentVariable("_CL_", kWorkaroundFlag); var clEnv = Environment.GetEnvironmentVariable("_CL_");
}
else if (!clEnv.Contains(kWorkaroundFlag)) if (string.IsNullOrEmpty(clEnv))
{ {
clEnv += " " + kWorkaroundFlag; Environment.SetEnvironmentVariable("_CL_", kWorkaroundFlag);
Environment.SetEnvironmentVariable("_CL_", clEnv); }
else if (!clEnv.Contains(kWorkaroundFlag))
{
clEnv += " " + kWorkaroundFlag;
Environment.SetEnvironmentVariable("_CL_", clEnv);
}
} }
} }
} }

View File

@ -7,6 +7,7 @@ using UnityEngine;
using Debug = UnityEngine.Debug; using Debug = UnityEngine.Debug;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Linq; using System.Linq;
using HybridCLR.Editor.Settings;
namespace HybridCLR.Editor.Installer namespace HybridCLR.Editor.Installer
{ {

View File

@ -1,5 +1,6 @@
using dnlib.DotNet; using dnlib.DotNet;
using HybridCLR.Editor.Meta; using HybridCLR.Editor.Meta;
using HybridCLR.Editor.Settings;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;

View File

@ -3,25 +3,30 @@ using System;
using UnityEditor; using UnityEditor;
using UnityEditorInternal; using UnityEditorInternal;
/// <summary> namespace HybridCLR.Editor.Settings
/// 监听编辑器状态,当编辑器重新 focus 时,重新加载实例,避免某些情景下 svn 、git 等外部修改了数据却无法同步的异常。
/// </summary>
[InitializeOnLoad]
public static class EditorStatusWatcher
{ {
public static Action OnEditorFocused;
static bool isFocused; /// <summary>
static EditorStatusWatcher() => EditorApplication.update += Update; /// 监听编辑器状态,当编辑器重新 focus 时,重新加载实例,避免某些情景下 svn 、git 等外部修改了数据却无法同步的异常。
static void Update() /// </summary>
[InitializeOnLoad]
public static class EditorStatusWatcher
{ {
if (isFocused != InternalEditorUtility.isApplicationActive) public static Action OnEditorFocused;
static bool isFocused;
static EditorStatusWatcher() => EditorApplication.update += Update;
static void Update()
{ {
isFocused = InternalEditorUtility.isApplicationActive; if (isFocused != InternalEditorUtility.isApplicationActive)
if (isFocused)
{ {
HybridCLRSettings.LoadOrCreate(); isFocused = InternalEditorUtility.isApplicationActive;
OnEditorFocused?.Invoke(); if (isFocused)
{
HybridCLRSettings.LoadOrCreate();
OnEditorFocused?.Invoke();
}
} }
} }
} }
} }

View File

@ -4,7 +4,8 @@ using UnityEditor;
using UnityEditor.Presets; using UnityEditor.Presets;
using UnityEngine; using UnityEngine;
using UnityEngine.UIElements; using UnityEngine.UIElements;
namespace HybridCLR.Editor
namespace HybridCLR.Editor.Settings
{ {
public class HybridCLRSettingsProvider : SettingsProvider public class HybridCLRSettingsProvider : SettingsProvider
{ {

View File

@ -1,6 +1,7 @@
using UnityEditorInternal; using UnityEditorInternal;
using UnityEngine; using UnityEngine;
namespace HybridCLR.Editor
namespace HybridCLR.Editor.Settings
{ {
[FilePath("ProjectSettings/HybridCLRSettings.asset")] [FilePath("ProjectSettings/HybridCLRSettings.asset")]
public class HybridCLRSettings : ScriptableSingleton<HybridCLRSettings> public class HybridCLRSettings : ScriptableSingleton<HybridCLRSettings>

View File

@ -2,35 +2,38 @@ using HybridCLR.Editor.Installer;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
public static class MenuProvider namespace HybridCLR.Editor.Settings
{ {
public static class MenuProvider
[MenuItem("HybridCLR/About HybridCLR", priority = 0)]
public static void OpenAbout() => Application.OpenURL("https://hybridclr.doc.code-philosophy.com/docs/intro");
[MenuItem("HybridCLR/Installer...", priority = 60)]
private static void Open()
{ {
InstallerWindow window = EditorWindow.GetWindow<InstallerWindow>("HybridCLR Installer", true);
window.minSize = new Vector2(800f, 500f); [MenuItem("HybridCLR/About HybridCLR", priority = 0)]
public static void OpenAbout() => Application.OpenURL("https://hybridclr.doc.code-philosophy.com/docs/intro");
[MenuItem("HybridCLR/Installer...", priority = 60)]
private static void Open()
{
InstallerWindow window = EditorWindow.GetWindow<InstallerWindow>("HybridCLR Installer", true);
window.minSize = new Vector2(800f, 500f);
}
[MenuItem("HybridCLR/Settings...", priority = 61)]
public static void OpenSettings() => SettingsService.OpenProjectSettings("Project/HybridCLR Settings");
[MenuItem("HybridCLR/Documents/Quick Start")]
public static void OpenQuickStart() => Application.OpenURL("https://hybridclr.doc.code-philosophy.com/docs/beginner/quickstart");
[MenuItem("HybridCLR/Documents/Performance")]
public static void OpenPerformance() => Application.OpenURL("https://hybridclr.doc.code-philosophy.com/docs/basic/performance");
[MenuItem("HybridCLR/Documents/FAQ")]
public static void OpenFAQ() => Application.OpenURL("https://hybridclr.doc.code-philosophy.com/docs/help/faq");
[MenuItem("HybridCLR/Documents/Common Errors")]
public static void OpenCommonErrors() => Application.OpenURL("https://hybridclr.doc.code-philosophy.com/docs/help/commonerrors");
[MenuItem("HybridCLR/Documents/Bug Report")]
public static void OpenBugReport() => Application.OpenURL("https://hybridclr.doc.code-philosophy.com/docs/help/issue");
} }
[MenuItem("HybridCLR/Settings...", priority = 61)]
public static void OpenSettings() => SettingsService.OpenProjectSettings("Project/HybridCLR Settings");
[MenuItem("HybridCLR/Documents/Quick Start")]
public static void OpenQuickStart() => Application.OpenURL("https://hybridclr.doc.code-philosophy.com/docs/beginner/quickstart");
[MenuItem("HybridCLR/Documents/Performance")]
public static void OpenPerformance() => Application.OpenURL("https://hybridclr.doc.code-philosophy.com/docs/basic/performance");
[MenuItem("HybridCLR/Documents/FAQ")]
public static void OpenFAQ() => Application.OpenURL("https://hybridclr.doc.code-philosophy.com/docs/help/faq");
[MenuItem("HybridCLR/Documents/Common Errors")]
public static void OpenCommonErrors() => Application.OpenURL("https://hybridclr.doc.code-philosophy.com/docs/help/commonerrors");
[MenuItem("HybridCLR/Documents/Bug Report")]
public static void OpenBugReport() => Application.OpenURL("https://hybridclr.doc.code-philosophy.com/docs/help/issue");
} }

View File

@ -5,7 +5,7 @@ using UnityEditor;
using UnityEditorInternal; using UnityEditorInternal;
using UnityEngine; using UnityEngine;
namespace HybridCLR.Editor namespace HybridCLR.Editor.Settings
{ {
public class ScriptableSingleton<T> : ScriptableObject where T : ScriptableObject public class ScriptableSingleton<T> : ScriptableObject where T : ScriptableObject
{ {

View File

@ -2,7 +2,7 @@ using UnityEditor;
using UnityEditor.Presets; using UnityEditor.Presets;
using UnityEngine; using UnityEngine;
namespace HybridCLR.Editor namespace HybridCLR.Editor.Settings
{ {
public class SettingsPresetReceiver : PresetSelectorReceiver public class SettingsPresetReceiver : PresetSelectorReceiver
{ {

View File

@ -5,6 +5,7 @@ using System.Linq;
using UnityEditor; using UnityEditor;
using UnityEditorInternal; using UnityEditorInternal;
using UnityEngine; using UnityEngine;
using HybridCLR.Editor.Settings;
namespace HybridCLR.Editor namespace HybridCLR.Editor