6 namespace HKI.Core.Scenes.Editor
11 [CustomEditor(typeof(SceneLoader))]
15 const string loadingSceneSPName =
"LoadingScene";
16 const string sceneLoaderControllerPrefabSPName =
"SceneLoaderControllerPrefab";
17 const string textLanguageSPName =
"TextLanguage";
18 const string doFadingSPName =
"DoFading";
19 const string fadeInTimeSPName =
"FadeInTime";
20 const string fadeOutTimeSPName =
"FadeOutTime";
22 SerializedProperty loadingSceneSP = null;
23 SerializedProperty sceneLoaderControllerPrefabSP = null;
24 SerializedProperty textLanguageSP = null;
25 SerializedProperty doFadingSP = null;
26 SerializedProperty fadeInTimeSP = null;
27 SerializedProperty fadeOutTimeSP = null;
30 [MenuItem(
"HKI/Core/Subsystems/Scene Loader")]
45 if (!
string.IsNullOrEmpty(rootFolder))
48 if (
string.IsNullOrEmpty(folder))
50 folder =
EditorHelper.
GetFolderFromUser(
"Select folder for the scene loader to be saved in",
"The given path for the scene loader is null or empty");
51 if (
string.IsNullOrEmpty(folder))
55 EditorUtility.DisplayProgressBar(
"Create scene loader",
"Create scene loader", 0.0f);
59 SerializedObject sceneLoaderSO =
new SerializedObject(sceneLoader);
61 sceneLoaderSO.Update();
63 sceneLoaderSO.FindProperty(textLanguageSPName).objectReferenceValue = FindAudioLanguage();
65 sceneLoaderSO.ApplyModifiedProperties();
69 EditorUtility.DisplayProgressBar(
"Create scene loader",
"Done", 1.0f);
71 Selection.activeObject = sceneLoader;
73 EditorUtility.ClearProgressBar();
79 loadingSceneSP = serializedObject.FindProperty(loadingSceneSPName);
80 sceneLoaderControllerPrefabSP = serializedObject.FindProperty(sceneLoaderControllerPrefabSPName);
81 textLanguageSP = serializedObject.FindProperty(textLanguageSPName);
82 doFadingSP = serializedObject.FindProperty(doFadingSPName);
83 fadeInTimeSP = serializedObject.FindProperty(fadeInTimeSPName);
84 fadeOutTimeSP = serializedObject.FindProperty(fadeOutTimeSPName);
90 serializedObject.Update();
92 EditorGUILayout.LabelField(
"General settings", EditorStyles.boldLabel);
94 EditorGUILayout.PropertyField(loadingSceneSP);
95 EditorGUILayout.PropertyField(sceneLoaderControllerPrefabSP);
97 EditorGUILayout.LabelField(
"Language settings", EditorStyles.boldLabel);
99 EditorGUILayout.PropertyField(textLanguageSP);
101 EditorGUILayout.LabelField(
"Fading settings", EditorStyles.boldLabel);
103 EditorGUILayout.PropertyField(doFadingSP);
104 EditorGUILayout.PropertyField(fadeInTimeSP);
105 EditorGUILayout.PropertyField(fadeOutTimeSP);
107 serializedObject.ApplyModifiedProperties();
112 string[] GUIDs = AssetDatabase.FindAssets(
"t:" + typeof(
Language).Name);
113 if (GUIDs.Length > 0)
115 for (
int i = 0; i < GUIDs.Length; i++)
117 string assetPath = AssetDatabase.GUIDToAssetPath(GUIDs[i]);
118 Object[] objs = AssetDatabase.LoadAllAssetsAtPath(assetPath);
119 string filename =
"Text Language";
120 foreach (Object obj
in objs)
122 if (obj.name == filename)
static void AddScriptableObjectToInitializer(ScriptableObject obj)
This function adds a scriptable object as a subasset to the initializer asset.
static Language FindAudioLanguage()
static bool FindAndSelectIfExists(string filter, string fileEnding=".asset")
static void CreateSceneLoader(string rootFolder=null)
This class containes helper functions for editor scripts.
static string GetFolderFromUser(string panelText, string errorMsg)
This ScriptableObject spawns the SceneLoaderController prefab and gives access to the SceneLoaderCont...
Custom inspector for the SceneLoader class.
override void OnInspectorGUI()
Special Variable enables the use of the SystemLanguage data type as a variable of the settings system...
This class contains the creation function of the menu for all HKI Core systems.
static void CreateSceneLoaderMenu()