mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-12 14:50:43 -05:00
Make GameObject hooks local to their respective plugin (#10)
* Make GameObject hooks local to their respective plugin * Add DontDestoryOnLoad() just incase
This commit is contained in:
parent
d19354ffef
commit
32f451db61
@ -2,19 +2,21 @@
|
||||
using SPT.Common;
|
||||
using SPT.Custom.Patches;
|
||||
using SPT.Custom.Utils;
|
||||
using SPT.Reflection.Utils;
|
||||
using BepInEx;
|
||||
using UnityEngine;
|
||||
using BepInEx.Logging;
|
||||
|
||||
namespace SPT.Custom
|
||||
{
|
||||
[BepInPlugin("com.SPT.custom", "SPT.Custom", SPTPluginInfo.PLUGIN_VERSION)]
|
||||
public class SPTCustomPlugin : BaseUnityPlugin
|
||||
{
|
||||
internal static GameObject HookObject;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
Logger.LogInfo("Loading: SPT.Custom");
|
||||
HookObject = new GameObject();
|
||||
DontDestroyOnLoad(HookObject);
|
||||
|
||||
try
|
||||
{
|
||||
@ -46,7 +48,7 @@ namespace SPT.Custom
|
||||
new AllowAirdropsInPvEPatch().Enable();
|
||||
new MemoryCollectionPatch().Enable();
|
||||
|
||||
HookObject.AddOrGetComponent<MenuNotificationManager>();
|
||||
HookObject.AddComponent<MenuNotificationManager>();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ public class DumpyLibPatch : ModulePatch
|
||||
public static void PatchPostfix(MenuScreen __instance)
|
||||
{
|
||||
// attach Monobehaviour so we can interact with UE
|
||||
HookObject._object.AddComponent<DumplyLibMono>();
|
||||
SPTDebuggingPlugin.HookObject.AddComponent<DumplyLibMono>();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,17 +5,22 @@ using SPT.Common.Utils;
|
||||
using SPT.Debugging.Patches;
|
||||
using BepInEx;
|
||||
using SPT.Custom.Models;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SPT.Debugging
|
||||
{
|
||||
[BepInPlugin("com.SPT.debugging", "SPT.Debugging", SPTPluginInfo.PLUGIN_VERSION)]
|
||||
public class SPTDebuggingPlugin : BaseUnityPlugin
|
||||
{
|
||||
internal static GameObject HookObject;
|
||||
|
||||
public static LoggingLevelResponse logLevel;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
Logger.LogInfo("Loading: SPT.Debugging");
|
||||
HookObject = new GameObject();
|
||||
DontDestroyOnLoad(HookObject);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -1,28 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace SPT.Reflection.Utils
|
||||
{
|
||||
public static class HookObject
|
||||
{
|
||||
public static GameObject _object
|
||||
{
|
||||
get
|
||||
{
|
||||
GameObject result = GameObject.Find("SPT.Hook");
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
result = new GameObject("SPT.Hook");
|
||||
Object.DontDestroyOnLoad(result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public static T AddOrGetComponent<T>() where T : MonoBehaviour
|
||||
{
|
||||
return _object.GetOrAddComponent<T>();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user