Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions scripts/DllCallbacks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace UnityNativeTool
{
/// <summary>
/// A place to implement you custom callbacks.
/// </summary>
public static class DllCallbacks
{
/// <summary>
/// This is called whenever a dll has been loaded.
/// </summary>
/// <param name="dllName">The name without preceding underscores or file extension.</param>
public static void OnDllLoaded(string dllName)
{
// Debug.Log("[dll] " + dllName + " dll loaded.");
}

/// <summary>
/// This is called whenever a dll is about to be unloaded.
/// </summary>
/// <param name="dllName">The name without preceding underscores or file extension.</param>
public static void OnBeforeDllUnload(string dllName)
{
// Debug.Log("[dll] " + dllName + " dll unloading...");
}

/// <summary>
/// This is called whenever a dll has been unloaded.
/// </summary>
/// <param name="dllName">The name without preceding underscores or file extension.</param>
public static void OnAfterDllUnload(string dllName)
{
// Debug.Log("[dll] " + dllName + " dll unloaded.");
}
}
}
3 changes: 3 additions & 0 deletions scripts/DllManipulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ public static void UnloadAll()
if (dll.handle != IntPtr.Zero)
{
LowLevelPluginManager.OnBeforeDllUnload(dll);
DllCallbacks.OnBeforeDllUnload(dll.name);

bool success = SysUnloadDll(dll.handle);
if (!success)
Debug.LogWarning($"Error while unloading DLL \"{dll.name}\" at path \"{dll.path}\"");

dll.ResetAsUnloaded();
DllCallbacks.OnAfterDllUnload(dll.name);
}
}
}
Expand Down Expand Up @@ -424,6 +426,7 @@ internal static void LoadTargetFunction(NativeFunction nativeFunction, bool igno
{
dll.loadingError = false;
LowLevelPluginManager.OnDllLoaded(dll);
DllCallbacks.OnDllLoaded(dll.name);
}
}

Expand Down