void OnSceneGUI() { GameController _gc = target as GameController; LevelEditorProfile _l = _gc.lep; if (_l != null) { for (int i = 0; i < _l.Levels.Count; i++) { if (i != showCustomObjectsIndex) { continue; } // Displays the rotation and position handle of the custom object for (int j = 0; j < _l.Levels[i].CustomSpawnPoints.Count; j++) { _l.Levels[i].customSpawnPoints[j] = Handles.PositionHandle(_l.Levels[i].CustomSpawnPoints[j], _l.Levels[i].CustomRotations[j]); _l.Levels[i].CustomRotations[j] = Handles.RotationHandle(_l.Levels[i].CustomRotations[j], _l.Levels[i].CustomSpawnPoints[j]); // Adds a label to the object Handles.Label(_l.Levels[i].CustomSpawnPoints[j] + new Vector3(0.01f, 0.05f), string.Format("Level #{0},\nObject: {1}\n x: {2}, y: {3}, z: {4}", (i + 1).ToString(), (_l.Levels[i].CustomObjects[j] != null) ? _l.Levels[i].CustomObjects[j].name : "null", _l.Levels[i].CustomSpawnPoints[j].x.ToString("0.00"), _l.Levels[i].CustomSpawnPoints[j].y.ToString("0.00"), _l.Levels[i].CustomSpawnPoints[j].z.ToString("0.00"))); } } } }
static void CreateLevelEditorProfile() { LevelEditorProfile _lep = CreateInstance <LevelEditorProfile>(); AssetDatabase.CreateAsset(_lep, "Assets/Resources/LevelEditorProfile.asset"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }
public override void OnInspectorGUI() { _lep = (LevelEditorProfile)target; // Goes through all the levels for (int i = 0; i < _lep.Levels.Count; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Level ID: ", _lep.Levels[i].ID.ToString()); if (GUILayout.Button("Insert Level")) { _lep.InsertLevel(i); } else if (GUILayout.Button("Delete Level")) { _lep.RemoveLevel(i); } EditorGUILayout.EndHorizontal(); _lep.Levels[i].SetLevelName(EditorGUILayout.TextField("Level Name:", _lep.Levels[i].LevelName)); _lep.Levels[i].SetUsingGoggles(EditorGUILayout.Toggle("Use Goggles:", _lep.Levels[i].UseGoggles)); _lep.Levels[i].SetUsingGloves(EditorGUILayout.Toggle("Use Gloves:", _lep.Levels[i].UsingGloves)); _lep.Levels[i].SetUsingBurner(EditorGUILayout.Toggle("Use Burner:", _lep.Levels[i].UsingBurner)); _lep.Levels[i].mixBeaker = EditorGUILayout.IntField("Mix beaker unit: ", _lep.Levels[i].MixBeaker); _lep.Levels[i].targetChemical = (ChemicalColor.ColorSelect)EditorGUILayout.EnumPopup("Target Chemical: ", _lep.Levels[i].targetChemical); GUILayout.Label(new GUIContent("Row 1", "The output chemical is automatically set based on the chemical reaction sheet")); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Add chemical") && _lep.Levels[i].Instruct1.Count < 3) { _lep.Levels[i].instruct1.Add(new Chemical.Traits()); } else if (GUILayout.Button("Remove chemical") && _lep.Levels[i].Instruct1.Count > 0) { _lep.Levels[i].instruct1.RemoveAt(_lep.Levels[i].Instruct1.Count - 1); } EditorGUILayout.EndHorizontal(); for (int j = 0; j < _lep.Levels[i].Instruct1.Count; j++) { _lep.Levels[i].instruct1[j] = (Chemical.Traits)EditorGUILayout.EnumPopup("Chemical #" + (j + 1).ToString(), _lep.Levels[i].Instruct1[j]); } GUILayout.Label(new GUIContent("Row 2", "Chemical #1 is automatically set to the output chemical from previous row")); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Add chemical") && _lep.Levels[i].Instruct2.Count < 2) { _lep.Levels[i].instruct2.Add(new Chemical.Traits()); } else if (GUILayout.Button("Remove chemical") && _lep.Levels[i].Instruct2.Count > 0) { _lep.Levels[i].instruct2.RemoveAt(_lep.Levels[i].Instruct2.Count - 1); } EditorGUILayout.EndHorizontal(); for (int j = 0; j < _lep.Levels[i].Instruct2.Count; j++) { _lep.Levels[i].instruct2[j] = (Chemical.Traits)EditorGUILayout.EnumPopup("Chemical #" + (j + 2).ToString(), _lep.Levels[i].Instruct2[j]); } GUILayout.Label(new GUIContent("Row 3", "Chemical #1 is automatically set to the output chemical from previous row")); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Add chemical") && _lep.Levels[i].Instruct3.Count < 2) { _lep.Levels[i].instruct3.Add(new Chemical.Traits()); } else if (GUILayout.Button("Remove chemical") && _lep.Levels[i].Instruct3.Count > 0) { _lep.Levels[i].instruct3.RemoveAt(_lep.Levels[i].Instruct3.Count - 1); } EditorGUILayout.EndHorizontal(); for (int j = 0; j < _lep.Levels[i].Instruct3.Count; j++) { _lep.Levels[i].instruct3[j] = (Chemical.Traits)EditorGUILayout.EnumPopup("Chemical #" + (j + 2).ToString(), _lep.Levels[i].Instruct3[j]); } EditorGUILayout.BeginHorizontal(); GUILayout.Label("Beaker groups:"); if (GUILayout.Button("Add Group")) { _lep.Levels[i].ChemicalGroups.Add(new Chemical.Traits()); } else if (GUILayout.Button("Remove Group")) { _lep.Levels[i].ChemicalGroups.RemoveAt(_lep.Levels[i].chemicalGroups.Count - 1); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginVertical(); for (int j = 0; j < _lep.Levels[i].ChemicalGroups.Count; j++) { _lep.Levels[i].chemicalGroups[j] = (Chemical.Traits)EditorGUILayout.EnumPopup("Group #" + (j + 1).ToString(), _lep.Levels[i].ChemicalGroups[j]); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Custom Spawning:"); if (GUILayout.Button("Add spawn")) { _lep.Levels[i].CustomObjects.Add(null); _lep.Levels[i].CustomSpawnPoints.Add(new Vector3()); _lep.Levels[i].CustomRotations.Add(Quaternion.identity); } else if (GUILayout.Button("Remove spawn")) { _lep.Levels[i].CustomObjects.RemoveAt(_lep.Levels[i].CustomObjects.Count - 1); _lep.Levels[i].CustomSpawnPoints.RemoveAt(_lep.Levels[i].CustomSpawnPoints.Count - 1); _lep.Levels[i].CustomRotations.RemoveAt(_lep.Levels[i].CustomRotations.Count - 1); } EditorGUILayout.EndHorizontal(); // Displays the custom objects in the level editor for (int j = 0; j < _lep.Levels[i].CustomObjects.Count; j++) { _lep.Levels[i].customObjects[j] = (GameObject)EditorGUILayout.ObjectField(_lep.Levels[i].CustomObjects[j], typeof(GameObject), false); } EditorGUILayout.Space(); Rect _lineRect = EditorGUILayout.GetControlRect(false, 3); _lineRect.height = 3; EditorGUI.DrawRect(_lineRect, Color.gray); EditorGUILayout.Space(); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Add new Level")) { _lep.AddLevel(); } EditorGUILayout.EndHorizontal(); if (GUI.changed) { _lep.Changed(); } }