GameModule.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Sirenix.OdinInspector;
  5. namespace KairoEngine.Core.ModuleSystem
  6. {
  7. [System.Serializable]
  8. public class GameModule
  9. {
  10. [SerializeField, HideInInspector] private string _name = "Empty Module Slot";
  11. [InlineButton("ResetModule", "Reset")]
  12. [InlineButton("RemoveModule", "Remove")]
  13. [FoldoutGroup("@_name"), HideIf("@module == null")] public bool enableModule = true;
  14. [SerializeReference, InlineProperty, HideLabel, FoldoutGroup("@_name"), OnValueChanged("UpdateModuleName"), PropertySpace(SpaceBefore = 5, SpaceAfter = 5)]
  15. public IGameModule module;
  16. [HideInInspector] public bool isInitialized = false;
  17. [HideInInspector] public GameConfig gameConfig;
  18. private void UpdateModuleName()
  19. {
  20. if(module != null) _name = module.name;
  21. else _name = "Empty Module Slot";
  22. }
  23. private void ResetModule()
  24. {
  25. module.Reset();
  26. }
  27. [FoldoutGroup("@_name"), HideIf("@module != null"), Button("Remove Empty Module")]
  28. private void RemoveModule()
  29. {
  30. gameConfig.modules.Remove(this);
  31. }
  32. }
  33. }