Singleton -> Instance

This commit is contained in:
Nahuel Rocchetti 2024-06-22 20:03:10 -03:00
parent c3fca9727f
commit 9ee540836f
5 changed files with 16 additions and 16 deletions

View file

@ -12,27 +12,27 @@ namespace OpenTS2.Audio
[RequireComponent(typeof(AudioSource))] [RequireComponent(typeof(AudioSource))]
public class MusicController : MonoBehaviour public class MusicController : MonoBehaviour
{ {
public static MusicController Singleton { get; private set; } public static MusicController Instance { get; private set; }
private AudioSource _audioSource; private AudioSource _audioSource;
private AudioAsset _currentAudioAsset; private AudioAsset _currentAudioAsset;
private void Awake() private void Awake()
{ {
Singleton = this; Instance = this;
_audioSource = GetComponent<AudioSource>(); _audioSource = GetComponent<AudioSource>();
} }
public static void PlayMusic(AudioAsset music) public static void PlayMusic(AudioAsset music)
{ {
Singleton._currentAudioAsset = music; Instance._currentAudioAsset = music;
Singleton._audioSource.clip = music.Clip; Instance._audioSource.clip = music.Clip;
Singleton._audioSource.volume = 1f; Instance._audioSource.volume = 1f;
Singleton._audioSource.Play(); Instance._audioSource.Play();
} }
public static void FadeOutMusic() public static void FadeOutMusic()
{ {
Singleton.StartCoroutine(Singleton.FadeOut()); Instance.StartCoroutine(Instance.FadeOut());
} }
IEnumerator FadeOut() IEnumerator FadeOut()

View file

@ -11,7 +11,7 @@ namespace OpenTS2.Diagnostic
/// </summary> /// </summary>
public class CheatConsoleController : MonoBehaviour, IConsoleOutput public class CheatConsoleController : MonoBehaviour, IConsoleOutput
{ {
public static CheatConsoleController Singleton { get; private set; } public static CheatConsoleController Instance { get; private set; }
public GameObject ConsoleParent; public GameObject ConsoleParent;
public InputField CheatInputField; public InputField CheatInputField;
public Text ConsoleOutput; public Text ConsoleOutput;
@ -24,7 +24,7 @@ namespace OpenTS2.Diagnostic
private void Awake() private void Awake()
{ {
Singleton = this; Instance = this;
CheatInputField.onValueChanged.AddListener(OnTextChanged); CheatInputField.onValueChanged.AddListener(OnTextChanged);
ConsoleParent.SetActive(false); ConsoleParent.SetActive(false);
DontDestroyOnLoad(this); DontDestroyOnLoad(this);

View file

@ -12,13 +12,13 @@ namespace OpenTS2.Engine
/// </summary> /// </summary>
public class AssetController : MonoBehaviour public class AssetController : MonoBehaviour
{ {
public static AssetController Singleton { get; private set; } public static AssetController Instance { get; private set; }
public static Font DefaultFont => Singleton._defaultFont; public static Font DefaultFont => Instance._defaultFont;
[SerializeField] [SerializeField]
private Font _defaultFont; private Font _defaultFont;
private void Awake() private void Awake()
{ {
Singleton = this; Instance = this;
} }
} }
} }

View file

@ -13,13 +13,13 @@ namespace OpenTS2.Engine
/// </summary> /// </summary>
public class MemoryController : MonoBehaviour public class MemoryController : MonoBehaviour
{ {
public static MemoryController Singleton { get; private set; } public static MemoryController Instance { get; private set; }
private static Action MarkedForRemoval; private static Action MarkedForRemoval;
private void Awake() private void Awake()
{ {
Singleton = this; Instance = this;
} }
public static void MarkForRemoval(Action action) public static void MarkForRemoval(Action action)

View file

@ -9,7 +9,7 @@ using UnityEngine;
namespace OpenTS2.UI { namespace OpenTS2.UI {
public class CursorController : MonoBehaviour public class CursorController : MonoBehaviour
{ {
public static CursorController Singleton { get; private set; } public static CursorController Instance { get; private set; }
public enum CursorType public enum CursorType
{ {
@ -65,7 +65,7 @@ namespace OpenTS2.UI {
private void Awake() private void Awake()
{ {
Singleton = this; Instance = this;
RegisterCursors(); RegisterCursors();
} }