A fork of Eusth's IPA
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

72 líneas
1.5KB

  1. using UnityEngine;
  2. namespace IllusionInjector
  3. {
  4. public class PluginComponent : MonoBehaviour
  5. {
  6. private CompositePlugin plugins;
  7. private bool freshlyLoaded = false;
  8. private bool quitting = false;
  9. public static PluginComponent Create()
  10. {
  11. return new GameObject("IPA_PluginManager").AddComponent<PluginComponent>();
  12. }
  13. private void Awake()
  14. {
  15. DontDestroyOnLoad(gameObject);
  16. plugins = new CompositePlugin(PluginManager.Plugins);
  17. plugins.OnApplicationStart();
  18. }
  19. private void Start()
  20. {
  21. OnLevelWasLoaded(Application.loadedLevel);
  22. }
  23. private void Update()
  24. {
  25. if (freshlyLoaded)
  26. {
  27. freshlyLoaded = false;
  28. plugins.OnLevelWasInitialized(Application.loadedLevel);
  29. }
  30. plugins.OnUpdate();
  31. }
  32. private void LateUpdate()
  33. {
  34. plugins.OnLateUpdate();
  35. }
  36. private void FixedUpdate()
  37. {
  38. plugins.OnFixedUpdate();
  39. }
  40. private void OnDestroy()
  41. {
  42. if (!quitting)
  43. {
  44. Create();
  45. }
  46. }
  47. private void OnApplicationQuit()
  48. {
  49. plugins.OnApplicationQuit();
  50. quitting = true;
  51. }
  52. private void OnLevelWasLoaded(int level)
  53. {
  54. plugins.OnLevelWasLoaded(level);
  55. freshlyLoaded = true;
  56. }
  57. }
  58. }