Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
0x7c13 committed Apr 8, 2024
1 parent d7eaf1e commit 46f0d21
Showing 1 changed file with 1 addition and 36 deletions.
37 changes: 1 addition & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,7 @@ A fully working runtime dark mode mod for Unity Editor on Windows with:
- Download the `UnityEditorDarkMode.dll` from [releases](https://github.com/0x7c13/UnityEditor-DarkMode/releases)

> **WARNING:** If you feel uncomfortable downloading a malicious DLL from a stranger like me, then you should not:) Take a look at later sections to see how it works and how to build it yourself if you prefer. Please do your own homework and make your own judgement. I offer this approach as a convenience for those who don't want to build a C++ project themselves.
- Now, you have two options:

Option 1: Add a Unity editor script to your project like below:
```C#
#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 or
// simply put the dll in the same directory as the script and use
// [DllImport("UnityEditorDarkMode.dll", EntryPoint = "DllMain")] instead
[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
_(); // Attach the dll to the Unity Editor
}
}
}
#endif
```
Option 2 (Unity 2021 or higher): Copy the DLL into your Unity project and apply below settings to the DLL in the Unity Editor inspector:
- Copy the DLL into your Unity project and apply below settings to the DLL in the Unity Editor inspector:

![dll-setting](screenshot-dll-setting.png?raw=true)

Expand Down Expand Up @@ -103,5 +70,3 @@ Ok, so what I have done on top of `ReaperThemeHackDll` is:
## Known issues
> I haven't found any major issues so far. Please let me know if you find any issues by creating an issue in this repository.

The reason why the DLL injection script is different for `Unity 2021 or later` and `Unity 2020 or earlier` is because the `[InitializeOnLoadMethod]` is getting called before the main window is created in earlier versions of Unity (2019, 2020). This is causing the sub-classing to fail since the main window is not found at dll attach time. So a simple workaround is to manually invoke the dll after the main window is created by sleeping the thread for some time. 100 ms is about right but you can adjust it if you encounter issues.

0 comments on commit 46f0d21

Please sign in to comment.