Skip to content

Commit 66df64f

Browse files
committed
Improve readme
1 parent bcf66ae commit 66df64f

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tool created mainly to solve the old problem with reloading [native plugins](htt
44

55
- Automatically unloads native plugins after stopping the game and loads them when needed.
66
- 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]`.
88
- [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).
99
- Works on Windows, Linux and Mac, but only on x86/x86_64 processors.
1010
- 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
2424
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).
2525

2626
## 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`).
2828
- 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`).
2929
- 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.
3333
- 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).
3434

3535
## 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.
3737

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.
3939

4040
## Limitations
4141
- Native callbacks `UnityRenderingExtEvent` and `UnityRenderingExtQuery` are do not fire.
4242
- Marshaling parameter attributes other than `[MarshalAs]`, `[In]` and `[Out]` are not supported.
4343
- 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.
4545
- 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).
4848

4949
## 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`.
5252
- 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.
5353

5454

@@ -62,7 +62,6 @@ Basically compile the file `./stubLluiPlugin.c` into the dynamic library (name i
6262
| With thread safety | ~430% |
6363

6464
## References
65-
Some of the sources I based my code on:
6665
- https://github.com/pardeike/Harmony
6766
- https://stackoverflow.com/a/9507589/7249108
6867
- http://runningdimensions.com/blog/?p=5

0 commit comments

Comments
 (0)