Skip to content
Merged
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
6 changes: 4 additions & 2 deletions scripts/Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ public class TriggerAttribute : Attribute
}

/// <summary>
/// Methods with this attribute are called directly after a native DLL has been loaded.
/// Methods with this attribute are called directly after a native DLL has been loaded. Native functions can be used within such a method.
/// This is called after <c>UnityPluginLoad</c>.<br/>
/// Such method must be <see langword="static"/> and either have no parameters or one parameter of type <see cref="NativeDll"/>
/// which indicates the state of the dll being loaded. Please treat this parameter as readonly.
/// which indicates the state of the dll being loaded. Please treat this parameter as readonly.<br/>
/// Preloaded: only called once all native methods have been loaded.
/// <br/><inheritdoc cref="TriggerAttribute"/>
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
Expand Down
11 changes: 10 additions & 1 deletion scripts/DllManipulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ public static void LoadAll()
{
LoadTargetFunction(nativeFunction, false);
}

// Notify that the dll and its functions have been loaded in preload mode
// This here allows use of native functions in the triggers
if(Options.loadingMode == DllLoadingMode.Preload)
InvokeCustomTriggers(_customLoadedTriggers, dll);
}
}
}
Expand Down Expand Up @@ -497,8 +502,12 @@ internal static void LoadTargetFunction(NativeFunction nativeFunction, bool igno
else
{
dll.loadingError = false;
InvokeCustomTriggers(_customLoadedTriggers, dll);
LowLevelPluginManager.OnDllLoaded(dll);

// Call the custom triggers once UnityPluginLoad has been called
// For Lazy mode call the triggers immediately, preload waits until all functions are loaded (in LoadAll)
if(Options.loadingMode == DllLoadingMode.Lazy)
InvokeCustomTriggers(_customLoadedTriggers, dll);
}
}

Expand Down