Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

希望可以根据Unity当前主题自动启用或禁用 #15

Open
QJJXK555 opened this issue Nov 28, 2024 · 1 comment
Open

希望可以根据Unity当前主题自动启用或禁用 #15

QJJXK555 opened this issue Nov 28, 2024 · 1 comment

Comments

@QJJXK555
Copy link

我使用Auto Dark Theme插件来自动切换主题,希望当使用亮色主题时就不要改变颜色了

@0x7c13
Copy link
Owner

0x7c13 commented Dec 4, 2024

https://discussions.unity.com/t/is-there-a-way-to-get-editor-background-color/67691/2
+
#if UNITY_EDITOR_WIN // Windows only, obviously
namespace Editor.Theme // Change this to your own namespace you like or simply remove it
{
using System.Runtime.InteropServices;
using UnityEditor;

public static class UnityEditorDarkMode
{
    // Change below path to the path of the downloaded dll
    [DllImport(@"C:\Users\<...>\Desktop\UnityEditorDarkMode.dll", EntryPoint = "DllMain")]
    private static extern void _();

    [InitializeOnLoadMethod]
    private static void __()
    {
        #if !UNITY_2021_1_OR_NEWER
        // [InitializeOnLoadMethod] is getting called before the editor
        // main window is created on earlier versions of Unity, so we
        // need to wait a bit here before attaching the dll.
        System.Threading.Thread.Sleep(100);
        #endif
        if (EditorGUIUtility.isProSkin)
        {
            _(); // Attach the dll to the Unity Editor
        }
    }
}

}
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants