initial commit
This commit is contained in:
46
Plugin.cs
Executable file
46
Plugin.cs
Executable file
@@ -0,0 +1,46 @@
|
||||
using BepInEx;
|
||||
using BepInEx.Logging;
|
||||
using BepInEx.Unity.IL2CPP;
|
||||
using Il2CppInterop.Runtime.Injection;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace AutoLight;
|
||||
|
||||
[BepInPlugin(PLUGIN_GUID, PLUGIN_NAME, PLUGIN_VERSION)]
|
||||
public class Plugin : BasePlugin
|
||||
{
|
||||
public const string PLUGIN_GUID = "de.mpburgmann.AutoLight";
|
||||
public const string PLUGIN_NAME = "AutoLight";
|
||||
public const string PLUGIN_VERSION = "1.0.0";
|
||||
internal static new ManualLogSource Log;
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
Log = base.Log;
|
||||
Log.LogInfo($"Plugin {PLUGIN_GUID} is loaded!");
|
||||
|
||||
SceneManager.sceneLoaded += (UnityAction<Scene, LoadSceneMode>) OnSceneLoaded;
|
||||
}
|
||||
|
||||
private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
{
|
||||
if (scene.name == "Main Scene")
|
||||
{
|
||||
ClassInjector.RegisterTypeInIl2Cpp<Behaviour>();
|
||||
GameObject gameObject = new("AutoLightBehaviour");
|
||||
Object.DontDestroyOnLoad(gameObject);
|
||||
gameObject.AddComponent<Behaviour>();
|
||||
}
|
||||
|
||||
if(scene.name == "Main Menu")
|
||||
{
|
||||
Object gameObject = GameObject.Find("AutoLightBehaviour");
|
||||
if(gameObject != null)
|
||||
{
|
||||
Object.Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user