You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.3 KiB
C#

using UnityEngine;
using System.Collections.Generic;
#if ODIN_INSPECTOR
using Sirenix.OdinInspector;
#endif
namespace HGR.Core.Singletons
{
[System.Serializable]
public sealed class Singleton
{
#if ODIN_INSPECTOR
[HorizontalGroup("Split")]
[VerticalGroup("Split/Left"), LabelWidth(100)]
#endif
[SerializeField] SingletonBase _singletonBase = null;
#if ODIN_INSPECTOR
[VerticalGroup("Split/Right"), LabelWidth(60)]
[Switch]
#endif
[SerializeField] bool _initialize = true;
public void Init()
{
if(_initialize)
_singletonBase?.Init();
}//Init() end
}//class end
#if ODIN_INSPECTOR
[HideMonoScript]
#endif
public class Initializer : MonoBehaviour
{
//===================================================
// FIELDS
//===================================================
#if ODIN_INSPECTOR
[Title("INITIALIZER", null, titleAlignment: TitleAlignments.Centered)]
#endif
[SerializeField] List<Singleton> _singletons = new List<Singleton>();
//===================================================
// METHODS
//===================================================
private void Awake() => _singletons.ForEach(s => s?.Init());
}//class end
}//namespace end