12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using TMPro;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- namespace BepInEx
- {
- //Adapted from https://github.com/Eusth/IPA/blob/0df8b1ecb87fdfc9e169365cb4a8fd5a909a2ad6/IllusionInjector/PluginComponent.cs
- public class BepInComponent : MonoBehaviour
- {
- List<BaseUnityPlugin> Plugins;
- private bool quitting = false;
- public static GameObject Create()
- {
- var obj = new GameObject("BepInEx_Manager");
- var manager = obj.AddComponent<BepInComponent>();
- manager.Plugins = new List<BaseUnityPlugin>();
- foreach (Type t in Chainloader.Plugins)
- {
- var plugin = (BaseUnityPlugin)obj.AddComponent(t);
- manager.Plugins.Add(plugin);
- Console.WriteLine($"Loaded [{plugin.Name}]");
- }
-
- return obj;
- }
- void Awake()
- {
- DontDestroyOnLoad(gameObject);
- }
- void Start()
- {
- Console.WriteLine("Component ready");
- }
- void OnDestroy()
- {
- if (!quitting)
- {
- Create();
- }
- }
- void OnApplicationQuit()
- {
- quitting = true;
- }
- }
- }
|