1 #pragma warning disable 0649 5 namespace HKI.Core.Init
10 [CreateAssetMenu(fileName =
"Initializer", menuName =
"HKI/General/Initializer", order = 0)]
17 [Header(
"Debug system")]
18 [SerializeField]
bool UseDebugSystem =
true;
23 [SerializeField] GameObject DebugSystemPrefab = null;
28 [Header(
"ScriptableObjects that are required at start")]
34 [Header(
"Prefabs that are required to be instantiated")]
40 [Header(
"Objects that are global")]
51 hideFlags = HideFlags.DontUnloadUnusedAsset;
53 if(DebugSystemPrefab != null && UseDebugSystem)
55 GameObject debugSystemGO = GameObject.Instantiate<GameObject>(DebugSystemPrefab);
56 DontDestroyOnLoad(debugSystemGO);
58 if (debugSystem == null)
59 Debug.LogError(
"Initalizer: the DebugSystemPrefab doesn't have a DebugSystem component on it!");
62 Debug.LogError(
"Initalizer: DebugSystemPrefab is null!");
64 if (ScriptableObjects != null)
66 for (
int i = 0; i < ScriptableObjects.Length; i++)
68 if(ScriptableObjects[i] != null)
74 Debug.LogError(
"Initalizer: Element " + ScriptableObjects[i].name +
" doesn't has a IInit implementation!");
77 Debug.LogWarning(
"Initalizer: Element " + i.ToString() +
" is null!");
84 for (
int i = 0; i < Prefabs.Length; i++)
85 Instantiate(Prefabs[i]);
This interface allows the initialization of anything by the Initialzer.
void Init()
This function will be called at the start of the game. It will initialize special system like setting...
ScriptableObject [] ScriptableObjects
All ScriptableObjects in this array that have an IInit interface implemented will be initialized...
This Initializer controlls the initialization of anything that implements the IInit interface...
Object [] Objects
This gloable objects will allways have a refernce during runtime and won't be destroyd by the garbage...
The DebugSystem controlls the pannel which includes the DebuConsole, SystemInfo, MemoryInfo and FPSIn...
GameObject [] Prefabs
All Prefabs in this array will be spawned at the start of the game.