mcpiroman / UnityNativeTool

Allows to unload native plugins in Unity3d editor
MIT License
184 stars 19 forks source link
c-sharp-library csharp interop native runtime unity unity-editor unity3d unity3d-plugin

Tool created mainly to solve the old problem with reloading native plugins without the need to reopen Unity Editor.

Overview

Installation

  1. Either download and add unity package from releases, or clone this repo into the assets of your project.

    • Clone it into the <Project Root>/Packages folder to use it as a local embedded package with upm.
  2. In project settings, set Api Compatibility Level to .NET 4.x or above. Edit > Project Settings > Player > Other Settings > Api Compatibility Level

  3. Check Allow 'unsafe' code. Edit > Project Settings > Player > Other Settings > Allow 'unsafe' code

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

Usage

Low level interface callbacks support

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.

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.

Limitations

Troubleshooting & advanced usage

Performance

Configuration Relative call time
Vanilla Unity 100%
Preloaded mode ~150%
Lazy mode ~190%
With thread safety ~430%

References