diff --git a/Assembly-CSharp/IMod.cs b/Assembly-CSharp/IMod.cs
index 0a0996a..5a8981d 100644
--- a/Assembly-CSharp/IMod.cs
+++ b/Assembly-CSharp/IMod.cs
@@ -29,6 +29,15 @@ public interface IMod : ILogger
/// List of tuples containg scene names and the respective actions.
(string, Func)[] PreloadSceneHooks();
+ ///
+ /// This function will be invoked on each gameObject preloaded through the system.
+ ///
+ /// The preloaded gameObject.
+ /// The scene the gameObject was preloaded from.
+ /// The path to the preloaded gameObject.
+ void InvokeOnGameObjectPreloaded(GameObject go, string sceneName, string goName);
+
+
///
/// Called after preloading of all mods.
///
diff --git a/Assembly-CSharp/Mod.cs b/Assembly-CSharp/Mod.cs
index 3e47694..21a9329 100644
--- a/Assembly-CSharp/Mod.cs
+++ b/Assembly-CSharp/Mod.cs
@@ -118,7 +118,7 @@ private string GetGlobalSettingsPath()
Log("Overriding Global Settings path with Mod directory");
return globalSettingsOverride;
}
-
+
return Path.Combine(Application.persistentDataPath, globalSettingsFileName);
}
@@ -148,6 +148,14 @@ public string GetName()
/// List of tuples containg scene names and the respective actions.
public virtual (string, Func)[] PreloadSceneHooks() => Array.Empty<(string, Func)>();
+ ///
+ /// This function will be invoked on each gameObject preloaded through the system.
+ ///
+ /// The preloaded gameObject.
+ /// The scene the gameObject was preloaded from.
+ /// The path to the preloaded gameObject.
+ public virtual void InvokeOnGameObjectPreloaded(GameObject go, string sceneName, string goName) { }
+
///
///
/// Called after preloading of all mods.
diff --git a/Assembly-CSharp/ModLoader.cs b/Assembly-CSharp/ModLoader.cs
index 886beaf..9594a54 100644
--- a/Assembly-CSharp/ModLoader.cs
+++ b/Assembly-CSharp/ModLoader.cs
@@ -249,6 +249,14 @@ Assembly Resolve(object sender, ResolveEventArgs args)
yield return pld.Preload(toPreload, preloadedObjects, sceneHooks);
}
+ foreach ((string sceneName, Dictionary goMap) in preloadedObjects.Values.SelectMany(x => x))
+ {
+ foreach ((string goName, GameObject go) in goMap)
+ {
+ OnPreloadedObject(go, sceneName, goName);
+ }
+ }
+
foreach (ModInstance mod in orderedMods)
{
if (mod.Error is not null)
@@ -466,6 +474,17 @@ internal static void UnloadMod(ModInstance mod, bool updateModText = true)
if (updateModText) UpdateModText();
}
+ public static void OnPreloadedObject(GameObject go, string sceneName, string goName)
+ {
+ foreach (ModInstance modInstance in ModInstances)
+ {
+ if (modInstance.Error is not null)
+ continue;
+
+ modInstance.Mod.InvokeOnGameObjectPreloaded(go, sceneName, goName);
+ }
+ }
+
// Essentially the state of a loaded **mod**. The assembly has nothing to do directly with mods.
public class ModInstance
{