[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 UnityEditor;
using System.Reflection;
using HybridCLR.Editor.Settings;
#if (UNITY_2020 || UNITY_2021) && UNITY_IOS
using UnityEditor.Build;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using UnityEngine;
namespace HybridCLR.Editor
namespace HybridCLR.Editor.BuildProcessors
{
public static class AddLil2cppSourceCodeToXcodeproj2021OrOlder
{

View File

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

View File

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

View File

@ -3,24 +3,28 @@ using System;
using UnityEditor.Build;
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 void OnPreprocessBuild(BuildReport report)
public class MsvcStdextWorkaround : IPreprocessBuildWithReport
{
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);
}
else if (!clEnv.Contains(kWorkaroundFlag))
{
clEnv += " " + kWorkaroundFlag;
Environment.SetEnvironmentVariable("_CL_", clEnv);
var clEnv = Environment.GetEnvironmentVariable("_CL_");
if (string.IsNullOrEmpty(clEnv))
{
Environment.SetEnvironmentVariable("_CL_", kWorkaroundFlag);
}
else if (!clEnv.Contains(kWorkaroundFlag))
{
clEnv += " " + kWorkaroundFlag;
Environment.SetEnvironmentVariable("_CL_", clEnv);
}
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,35 +2,38 @@ using HybridCLR.Editor.Installer;
using UnityEditor;
using UnityEngine;
public static class MenuProvider
namespace HybridCLR.Editor.Settings
{
[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()
public static class MenuProvider
{
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 UnityEngine;
namespace HybridCLR.Editor
namespace HybridCLR.Editor.Settings
{
public class ScriptableSingleton<T> : ScriptableObject where T : ScriptableObject
{

View File

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

View File

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