BaseUnityPlugin.cs 730 B

12345678910111213141516171819202122232425262728293031
  1. using BepInEx.Bootstrap;
  2. using BepInEx.Configuration;
  3. using BepInEx.Contract;
  4. using BepInEx.Logging;
  5. using UnityEngine;
  6. namespace BepInEx
  7. {
  8. /// <summary>
  9. /// The base plugin type that is used by the BepInEx plugin loader.
  10. /// </summary>
  11. public abstract class BaseUnityPlugin : MonoBehaviour
  12. {
  13. protected ManualLogSource Logger { get; }
  14. protected ConfigFile Config { get; }
  15. protected PluginInfo Info { get; }
  16. protected BaseUnityPlugin()
  17. {
  18. var metadata = MetadataHelper.GetMetadata(this);
  19. Info = Chainloader.PluginInfos[metadata.GUID];
  20. Logger = Logging.Logger.CreateLogSource(metadata.Name);
  21. Config = new ConfigFile(Utility.CombinePaths(Paths.ConfigPath, metadata.GUID + ".cfg"), false);
  22. }
  23. }
  24. }