You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-13Lines changed: 12 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ Tool created mainly to solve the old problem with reloading [native plugins](htt
4
4
5
5
- Automatically unloads native plugins after stopping the game and loads them when needed.
6
6
- You can unload/reload them manually, even when the game is running.
7
-
- No code change is required (use usual `[DllImport]`).
7
+
- No code change is required - use usual `[DllImport]`.
8
8
-[Low level interface](https://docs.unity3d.com/Manual/NativePluginInterface.html) callbacks `UnityPluginLoad` and `UnityPluginUnload` do fire - to enable them see [this section](#low-level-interface-callbacks-support).
9
9
- Works on Windows, Linux and Mac, but only on x86/x86_64 processors.
10
10
- Ability to log native calls to file in order to diagnose crashes caused by them.
@@ -24,31 +24,31 @@ Tool created mainly to solve the old problem with reloading [native plugins](htt
24
24
4. One of the gameobjects in the scene needs to have `DllManipulatorScript` on it. (This script calls `DontDestroayOnLoad(gameObject)` and deletes itself when a duplicate is found in order to behave nicely when switching scenes).
25
25
26
26
## Usage
27
-
- Your plugin files must be at path specified in options. By default, just add __ (two underscores) at the beginning of your dll files in the Assets/Plugins folder (e.g. on Windows, plugin named `FastCalcs` should be at path `Assets\Plugins\__FastCalcs.dll`).
27
+
- Your plugin files must be at path specified in options. By default, just add `__` (two underscores) at the beginning of your dll files in the Assets/Plugins folder (e.g. on Windows, plugin named `FastCalcs` should be at path `Assets\Plugins\__FastCalcs.dll`).
28
28
- By default, all native functions in the main scripts assembly will be mocked (i.e. handled by this tool instead of Unity, allowing them to be unloaded). You can change this in options and use provided attributes to specify that yourself (they are in `UnityNativeTool` namespace, file `Attributes.cs`).
29
29
- Options are accessible via `DllManipulatorScript` editor or window.
30
-
- You can get callbacks in C# when the dll load state has changed with attributes like `[NativeDllLoadedTrigger]`. See `Attributes.cs`.
31
-
-Unload and load all DLLs via shortcut `Alt+D` and `Alt+Shfit+D` respectively. Editable in the Shortcut Manager for 2019.1+
32
-
- Although this tool presumably works in the built game, it's intended to be used only during developement.
30
+
- You can also unload and load all DLLs via shortcut, `Alt+D` and `Alt+Shfit+D` respectively. Editable in the Shortcut Manager for 2019.1+
31
+
-You can get callbacks in your C# code when the load state of a DLL has changed with attributes like `[NativeDllLoadedTrigger]`. See `Attributes.cs`.
32
+
- Although this tool presumably works in the built game, it's intended to be used only during development.
33
33
- If something doesn't work, first check out available options (and read their descriptions), then [report an issue](https://github.com/mcpiroman/UnityNativeTool/issues/new).
34
34
35
35
## Low level interface callbacks support
36
-
For that, you'll need a `StubLluiPlugin`native plugin. I only embed it into .unitypackage for x64 Windows platform, so for other cases you'll need to compile it manually:
36
+
For that, you'll need a `StubLluiPlugin`DLL. I only embed it into .unitypackage for x64 Windows platform, so for other cases you'll need to compile it manually.
37
37
38
-
Basically compile the file `./stubLluiPlugin.c` into the dynamic library (name it `StubLluiPlugin`, no underscores) and put into Unity like you would do with other plugins.
38
+
This is, compile the file `./stubLluiPlugin.c` into the dynamic library (name it `StubLluiPlugin`, no underscores) and put into Unity like you would do with other plugins.
39
39
40
40
## Limitations
41
41
- Native callbacks `UnityRenderingExtEvent` and `UnityRenderingExtQuery` are do not fire.
42
42
- Marshaling parameter attributes other than `[MarshalAs]`, `[In]` and `[Out]` are not supported.
43
43
- Properties `MarshalCookie`, `MarshalType`, `MarshalTypeRef` and `SafeArrayUserDefinedSubType` on `[MarshalAs]` attribute are not supported (due to [Mono bug](https://github.com/mono/mono/issues/12747)).
44
-
- Explicitly specifying `UnmanagedType.LPArray` in `[MarshalAs]` is not supported (due to [another Mono bug](https://github.com/mono/mono/issues/16570)). Note that this should be the default for array types, so in trivial situations you wouldn't need to use it anyway.
44
+
- Explicitly specifying `UnmanagedType.LPArray` in `[MarshalAs]` is not supported (due to [another Mono bug](https://github.com/mono/mono/issues/16570)). Note that this should be the default for array types, so in trivial situations you don't need to use it anyway.
45
45
- Properties `ExactSpelling` and `PreserveSig` of `[DllImport]` attribute are not supported.
46
-
- Calling native functions from static constuctors generally won't work. Although the rules are more relaxed, you usually shouldn't even atempt to do that in the first place. Note that in C# _[static constructors don't fire on their own](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/static-constructors#remarks)_.
47
-
-Threads that execute past `OnApplicationQuit` event are not-very-well handled (usually not something to worry about).
46
+
- Calling native functions from static constructors generally won't work. Although the rules are more relaxed, you usually shouldn't even attempt to do that in the first place. Note that in C# _[static constructors don't fire on their own](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/static-constructors#remarks)_.
47
+
-Additional threads that execute past `OnApplicationQuit` event are not-very-well handled (usually not something to worry about).
48
48
49
49
## Troubleshooting & advanced usage
50
-
- The path in the `DLL path pattern` option cannot be simply set to `{assets}/Plugins/{name}.dll` as it would interfer with Unity's plugin loading - hence the undersocres.
51
-
- In version `2019.3.x` Unity changed behaviour of building. If you want to use this tool in the built game (although preferiably just for developement) you should store your plugins in architecture-specific subfolders and update the `DLL path pattern` option accordingly, e.g. `{assets}/Plugins/x86_64/__{name}.dll`.
50
+
- The path in the `DLL path pattern` option cannot be simply set to `{assets}/Plugins/{name}.dll` as it would interfere with Unity's plugin loading - hence the underscores.
51
+
- In version `2019.3.x` Unity changed behaviour of building. If you want to use this tool in the built game (although preferably just for development) you should store your plugins in architecture-specific subfolders and update the `DLL path pattern` option accordingly, e.g. `{assets}/Plugins/x86_64/__{name}.dll`.
52
52
- The `UnityNativeTool.DllManipulatorScript` script by default has an execution order of -10000 to make it run first. If you have a script that has even lower execution order and that scripts calls a DLL, then you should make sure that `UnityNativeTool.DllManipulatorScript` runs before it, e.g. by further lowering its execution order.
53
53
54
54
@@ -62,7 +62,6 @@ Basically compile the file `./stubLluiPlugin.c` into the dynamic library (name i
0 commit comments