Skip to content

Commit 004b328

Browse files
committed
Support OptionalAttribute
1 parent 66df64f commit 004b328

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

README.md

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

2626
## Usage
2727
- 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-
- 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`).
28+
- By default, all `extern` methods 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.
3030
- 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+
3131
- You can get callbacks in your C# code when the load state of a DLL has changed with attributes like `[NativeDllLoadedTrigger]`. See `Attributes.cs`.
@@ -38,8 +38,8 @@ For that, you'll need a `StubLluiPlugin` DLL. I only embed it into .unitypackage
3838
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
41-
- Native callbacks `UnityRenderingExtEvent` and `UnityRenderingExtQuery` are do not fire.
42-
- Marshaling parameter attributes other than `[MarshalAs]`, `[In]` and `[Out]` are not supported.
41+
- Native callbacks `UnityRenderingExtEvent` and `UnityRenderingExtQuery` do not fire.
42+
- Only some basic attributes on parameters of `extern` methods (such as `[MarshalAs]` or `[In]`) are 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)).
4444
- 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.

scripts/DllManipulator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ private static CustomAttributeBuilder CreateAttributeBuilderFromAttributeInstanc
482482
}
483483
case InAttribute _:
484484
case OutAttribute _:
485+
case OptionalAttribute _:
485486
{
486487
var ctor = attrType.GetConstructor(Type.EmptyTypes);
487488
return new CustomAttributeBuilder(ctor, Array.Empty<object>(), Array.Empty<PropertyInfo>(), Array.Empty<object>(),

0 commit comments

Comments
 (0)