// Draw the Initialization screen if the engine hasn't yet been "enabled" private void Draw_Initialization() { VerticalBox(() => { Label("Crunch Engine", true); }); ScrollBox(() => { VerticalBox(() => { Label("Initialize", true); if (hasCrunchEngine) { if (!hasCurrentData) { EditorGUILayout.LabelField("You haven't initialized your current Preset yet. If you have not created one yet, please do so using the button. If you already have a Preset, assign it in the field."); EditorStyles.label.wordWrap = true; Horizontal(() => { GUILayout.Space(20); Label("Create New Preset: ", false); GUILayout.FlexibleSpace(); if (GUILayout.Button("Create New")) { CrunchEngineData data = ScriptableObject.CreateInstance <CrunchEngineData>(); AssetDatabase.CreateAsset(data, "Assets/Megabite Studios/Crunch/Presets/New Preset.asset"); AssetDatabase.SaveAssets(); EditorUtility.FocusProjectWindow(); Selection.activeObject = data; crunchEngine.AssignEngineData(data); hasCurrentData = true; } }); Horizontal(() => { GUILayout.Space(20); Label("Or Assign Existing: ", false); GUILayout.FlexibleSpace(); EditorGUI.BeginChangeCheck(); crunchEngine.CurrentData = (CrunchEngineData)EditorGUILayout.ObjectField(crunchEngine.CurrentData, typeof(CrunchEngineData), false); if (EditorGUI.EndChangeCheck()) { if (crunchEngine.CurrentData != null) { hasCurrentData = true; if (!hasCrunchEngine) { GameObject go = new GameObject(); go.transform.position = Vector3.zero; go.transform.localScale = Vector3.one; go.transform.rotation = Quaternion.identity; go.name = "CrunchEngine"; crunchEngine = go.AddComponent <CrunchEngine>(); hasCrunchEngine = true; } } } }); } } else { EditorGUILayout.LabelField("You haven't initialized Crunch Engine yet. Use the button below to begin."); EditorStyles.label.wordWrap = true; EditorGUILayout.LabelField("NOTE: You will receive this message if the CrunchEngine GameObject is inactive."); EditorStyles.label.wordWrap = true; GUILayout.BeginHorizontal(); if (GUILayout.Button("Begin")) { GameObject go = new GameObject(); go.transform.position = Vector3.zero; go.transform.localScale = Vector3.one; go.transform.rotation = Quaternion.identity; go.name = "CrunchEngine"; go.AddComponent <CrunchEngine>(); crunchEngine = go.GetComponent <CrunchEngine>(); hasCrunchEngine = true; } GUILayout.EndHorizontal(); } }); }); }
public void AssignEngineData(CrunchEngineData newData) { currentData = newData; }