BaseUnityPlugin.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using BepInEx.Configuration;
  2. using BepInEx.Logging;
  3. using UnityEngine;
  4. namespace BepInEx
  5. {
  6. /// <summary>
  7. /// The base plugin type that is used by the BepInEx plugin loader.
  8. /// </summary>
  9. public abstract class BaseUnityPlugin : MonoBehaviour
  10. {
  11. /// <summary>
  12. /// Information about this plugin as it was loaded.
  13. /// </summary>
  14. public BepInPlugin Metadata { get; }
  15. /// <summary>
  16. /// Logger instance tied to this plugin.
  17. /// </summary>
  18. protected ManualLogSource Logger { get; }
  19. /// <summary>
  20. /// Default config file tied to this plugin. The config file will not be created until
  21. /// any settings are added and changed, or <see cref="ConfigFile.Save"/> is called.
  22. /// </summary>
  23. protected ConfigFile Config { get; }
  24. /// <summary>
  25. /// Create a new instance of a plugin and all of its tied in objects.
  26. /// </summary>
  27. protected BaseUnityPlugin()
  28. {
  29. Metadata = MetadataHelper.GetMetadata(this);
  30. Logger = Logging.Logger.CreateLogSource(Metadata.Name);
  31. Config = new ConfigFile(Utility.CombinePaths(Paths.ConfigPath, Metadata.GUID + ".cfg"), false, this);
  32. }
  33. }
  34. }