using UnityEngine; namespace Management { /// /// Global access pattern for services. /// If you need a component or some data that needs to be used in many places, here's a good spot. /// public class Services : MonoBehaviour { // Enforce singleton pattern public static Services Instance { get; private set; } // BGM service for playing/changing background music. public BGM BGM => bgm; // SFX service to serve as single spot SFX plays from. public SFX SFX => sfx; [SerializeField] private BGM bgm; [SerializeField] private SFX sfx; private void Awake() { // enforce singleton if (Instance != null && Instance != this) { Destroy(gameObject); return; } Instance = this; // survive scene reloads DontDestroyOnLoad(gameObject); } } }