5 namespace HKI.Core.Init.Editor
17 [MenuItem(
"HKI/Core/Create Initializer and all subsystems")]
20 string rootFolder =
EditorHelper.
GetFolderFromUser(
"Select root folder for all systems to be saved in",
"The given path for the systems is null or empty");
22 if(!CreateInitializer(rootFolder))
39 [MenuItem(
"HKI/Core/Subsystems/Initializer")]
57 if(!
string.IsNullOrEmpty(rootFolder))
60 if(
string.IsNullOrEmpty(folder))
62 folder =
EditorHelper.
GetFolderFromUser(
"Select folder for initializer to be saved in",
"The given path for the initializer is null or empty");
63 if(
string.IsNullOrEmpty(folder))
67 EditorUtility.DisplayProgressBar(
"Create Initializer",
"Create Initializer", 0.0f);
69 if (!folder.EndsWith(
"/Resources/"))
70 folder +=
"Resources/";
72 EditorUtility.DisplayProgressBar(
"Create Initializer",
"Create Initializer", 0.25f);
76 EditorUtility.ClearProgressBar();
92 string[] settingSystemGUIDs = AssetDatabase.FindAssets(
"t:Initializer");
93 if(settingSystemGUIDs.Length > 0)
95 for(
int i = 0; i < settingSystemGUIDs.Length; i++)
97 string assetPath = AssetDatabase.GUIDToAssetPath(settingSystemGUIDs[i]);
98 if(assetPath.EndsWith(
"Initializer.asset"))
99 initializer = (
Initializer)AssetDatabase.LoadMainAssetAtPath(assetPath);
103 if(initializer == null)
106 SerializedObject initializerSO =
new SerializedObject(initializer);
107 SerializedProperty scriptableObjectsSP = initializerSO.FindProperty(
"ScriptableObjects");
109 if(scriptableObjectsSP == null)
112 for(
int i = 0; i < scriptableObjectsSP.arraySize; i++)
114 if(scriptableObjectsSP.GetArrayElementAtIndex(i).objectReferenceValue == obj)
118 initializerSO.Update();
121 for(
int i = 0; i < scriptableObjectsSP.arraySize; i++)
123 if (scriptableObjectsSP.GetArrayElementAtIndex(i).objectReferenceValue == null)
125 scriptableObjectsSP.GetArrayElementAtIndex(i).objectReferenceValue = obj;
132 scriptableObjectsSP.InsertArrayElementAtIndex(scriptableObjectsSP.arraySize);
133 scriptableObjectsSP.GetArrayElementAtIndex(scriptableObjectsSP.arraySize - 1).objectReferenceValue = obj;
136 initializerSO.ApplyModifiedProperties();
static void AddScriptableObjectToInitializer(ScriptableObject obj)
This function adds a scriptable object as a subasset to the initializer asset.
Custom inspector for the AudioSystem class.
static bool FindAndSelectIfExists(string filter, string fileEnding=".asset")
static void CreateSceneLoader(string rootFolder=null)
static void CreateLocalizationSystem(string rootFolder=null)
This functio creates a localization system.
static void CreateSettingsSystem(string rootFolder=null)
static bool CreateInitializer(string rootFolder=null)
This function actualy creates the initializer.
This class containes helper functions for editor scripts.
static string GetFolderFromUser(string panelText, string errorMsg)
Custom inspector for the SceneLoader class.
This Initializer controlls the initialization of anything that implements the IInit interface...
static void CreateInitializerMenu()
This function is for the menu item that creates only the initializer.
This class contains the creation function of the menu for all HKI Core systems.
static void CreateInitializerAndAllSubsystems()
This function is for the menu item that creates the initializer and all subsystems.
Custom inspector for the SettingsSystem class.
Custom inspector for the LocalizationSystem class.
static void CreateAudioSystem(string rootFolder=null)
This function creates audio systems and all the other required assets like playlists for the HKI Core...