/// <summary> /// Display settings /// </summary> void DrawSettings() { // Draw a header for the Spawner Area global settings EditorGUILayout.LabelField("Global settings", TDS_EditorUtility.HeaderStyle); TDS_EditorUtility.Toggle("is Looping", "Is the area start again when all the waves are cleared.", isLooping); TDS_EditorUtility.Toggle("Is Activated by event", "Does the area start by event or by trigger.", isActivatedByEvent); GUILayout.Space(10); EditorGUILayout.BeginHorizontal(); if (TDS_EditorUtility.Button("WAVES", "Wrap / Unwrap Waves", TDS_EditorUtility.HeaderStyle)) { AreWavesUnfolded = !areWavesUnfolded; } GUITools.ActionButton("Add Wave", waves.InsertArrayElementAtIndex, waves.arraySize, Color.white, Color.white); EditorGUILayout.EndHorizontal(); if (areWavesUnfolded) { for (int i = 0; i < waves.arraySize; i++) { GUILayout.Space(10); DrawWave(i); } } }
/// <summary> /// Sraw spawner Area Editor /// </summary> void DrawSpawnerAreaEditor() { // Make a space at the beginning of the editor GUILayout.Space(10); Color _originalColor = GUI.backgroundColor; GUI.backgroundColor = TDS_EditorUtility.BoxDarkColor; EditorGUILayout.BeginVertical("HelpBox"); TDS_EditorUtility.RadioToggle("Is Ready", "", isReady); TDS_EditorUtility.RadioToggle("Is Activated", "", isActivated); EditorGUILayout.EndVertical(); GUILayout.Space(10); EditorGUILayout.BeginVertical("HelpBox"); // Button to show or not the Character class settings if (TDS_EditorUtility.Button("Settings", "Wrap / unwrap settings", TDS_EditorUtility.HeaderStyle)) { AreSpawnerAreaSettingsUnfolded = !areSpawnerAreaSettingsUnfolded; } // If unfolded, draws the custom editor for the sttings if (areSpawnerAreaSettingsUnfolded) { DrawSettings(); } EditorGUILayout.EndVertical(); GUILayout.Space(15); GUI.backgroundColor = TDS_EditorUtility.BoxDarkColor; EditorGUILayout.BeginVertical("HelpBox"); // Button to show or not the Character class components if (TDS_EditorUtility.Button("Events", "Wrap / Unwrap Events settings", TDS_EditorUtility.HeaderStyle)) { AreSpawerAreaEventsUnfolded = !areSpawerAreaEventsUnfolded; } // If unfolded, draws the custom editor for the Components & References if (areSpawerAreaEventsUnfolded) { DrawEvents(); } EditorGUILayout.EndVertical(); GUILayout.Space(15); DrawSpawnedEnemies(); // Applies all modified properties on the SerializedObjects serializedObject.ApplyModifiedProperties(); GUI.backgroundColor = _originalColor; }
/// <summary> /// Draw the split settings /// </summary> private void DrawSplittingSettings() { if (IsEnemyUnfolded) { EditorGUILayout.Space(); EditorGUILayout.BeginVertical("Box"); //Draw a header for the enemy spinning settings if (TDS_EditorUtility.Button("Splitting Enemies", "Wrap / unwrap splitting enemies", TDS_EditorUtility.HeaderStyle)) { AreSplittingSettingsUnfolded = !areSplittingSettingsUnfolded; } if (areSplittingSettingsUnfolded) { EditorGUILayout.Space(); for (int i = 0; i < splitingEnemiesNames.arraySize; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(splitingEnemiesNames.GetArrayElementAtIndex(i).stringValue, TDS_EditorUtility.HeaderStyle); GUITools.ActionButton("X", RemoveSettingsAtIndex, i, Color.white, Color.black, "Remove this spliting enemy"); Repaint(); serializedObject.ApplyModifiedProperties(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); TDS_Enemy _e = null; _e = EditorGUILayout.ObjectField("Add Splitting Enemy", _e, typeof(TDS_Enemy), false) as TDS_Enemy; if (_e != null) { splitingEnemiesNames.InsertArrayElementAtIndex(0); splitingEnemiesNames.GetArrayElementAtIndex(0).stringValue = _e.EnemyName; splitingPosition.InsertArrayElementAtIndex(0); splitingPosition.GetArrayElementAtIndex(0).vector3Value = Vector3.forward; Repaint(); } EditorGUILayout.Space(); TDS_EditorUtility.ObjectField("Splitting Portrait", "Portrait of the splitting enemies", splittingPortrait, typeof(GameObject)); serializedObject.ApplyModifiedProperties(); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); } }
/// <summary> /// Draws the editor for the events. /// </summary> public void DrawEvents(SerializedProperty _events, ref bool[] _foldouts) { // Button to add a new event GUI.backgroundColor = TDS_EditorUtility.BoxLightColor; GUI.color = Color.green; if (TDS_EditorUtility.Button("+", "Add a new event", EditorStyles.miniButton)) { _events.InsertArrayElementAtIndex(0); _events.GetArrayElementAtIndex(0).FindPropertyRelative("Name").stringValue = "New Event"; bool[] _newFoldouts = new bool[_foldouts.Length + 1]; Array.Copy(_foldouts, 0, _newFoldouts, 1, _foldouts.Length); _foldouts = _newFoldouts; } GUI.color = Color.white; GUI.backgroundColor = TDS_EditorUtility.BoxDarkColor; for (int _i = 0; _i < _events.arraySize; _i++) { GUILayout.Space(5); GUI.backgroundColor = TDS_EditorUtility.BoxLightColor; EditorGUILayout.BeginVertical("Box"); SerializedProperty _event = _events.GetArrayElementAtIndex(_i); SerializedProperty _eventName = _event.FindPropertyRelative("Name"); EditorGUILayout.BeginHorizontal(); // Button to show or not this event if (TDS_EditorUtility.Button(_eventName.stringValue, "Wrap / unwrap this event", TDS_EditorUtility.HeaderStyle)) { _foldouts[_i] = !_foldouts[_i]; } GUILayout.FlexibleSpace(); // BUttons to change the event position in the list if ((_i > 0) && TDS_EditorUtility.Button("▲", "Move this element up", EditorStyles.miniButton)) { _events.MoveArrayElement(_i, _i - 1); } if ((_i < _events.arraySize - 1) && TDS_EditorUtility.Button("▼", "Move this element down", EditorStyles.miniButton)) { _events.MoveArrayElement(_i, _i + 1); } // Button to delete this event GUI.color = Color.red; if (TDS_EditorUtility.Button("X", "Delete this event", EditorStyles.miniButton)) { _events.DeleteArrayElementAtIndex(_i); bool[] _newFoldouts = new bool[_foldouts.Length - 1]; Array.Copy(_foldouts, 0, _newFoldouts, 0, _i); Array.Copy(_foldouts, _i + 1, _newFoldouts, _i, _foldouts.Length - (_i + 1)); _foldouts = _newFoldouts; break; } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); // If unfolded, draws this event if (_foldouts[_i]) { SerializedProperty _eventType = _event.FindPropertyRelative("eventType"); SerializedProperty _doRequireType = _event.FindPropertyRelative("doRequireSpecificPlayerType"); TDS_EditorUtility.TextField("Name", "Name of this event", _eventName); GUILayout.Space(3); TDS_EditorUtility.PropertyField("Event Type", "Type of this event", _eventType); CustomEventType _eventTypeValue = (CustomEventType)_eventType.enumValueIndex; if (_eventType.enumValueIndex > 7) { _eventTypeValue += 13; } TDS_EditorUtility.FloatField("Delay", "Delay before starting this event", _event.FindPropertyRelative("delay")); GUILayout.Space(3); TDS_EditorUtility.Toggle("Require specific Player type", "Should this event require a specific player type to be triggered", _doRequireType); if (_doRequireType.boolValue) { TDS_EditorUtility.PropertyField("Required type of Player", "Required type of player to trigger this event", _event.FindPropertyRelative("playerType")); } GUILayout.Space(5); switch (_eventTypeValue) { case CustomEventType.CameraMovement: TDS_EditorUtility.PropertyField("Target", "Target to make the camera look ", _event.FindPropertyRelative("eventTransform")); TDS_EditorUtility.FloatField("Duration", "Time to look at the target", _event.FindPropertyRelative("cameraWaitTime")); TDS_EditorUtility.FloatField("Speed Coef", "Coefficient applied to the speed of the camera.", _event.FindPropertyRelative("eventFloat")); break; case CustomEventType.DesactiveInfoBox: break; case CustomEventType.DisplayInfoBox: TDS_EditorUtility.TextField("Text ID", "ID of the text to use for the Info Box", _event.FindPropertyRelative("eventString")); break; case CustomEventType.Instantiate: TDS_EditorUtility.PropertyField("Prefab", "Prefab to instantiate", _event.FindPropertyRelative("prefab")); TDS_EditorUtility.PropertyField("Instantiation transform reference", "Transform to use as reference for position & rotation for the transform of the instantiated object", _event.FindPropertyRelative("eventTransform")); break; case CustomEventType.InstantiatePhoton: TDS_EditorUtility.PropertyField("Prefab", "Prefab to instantiate", _event.FindPropertyRelative("prefab")); TDS_EditorUtility.PropertyField("Instantiation transform reference", "Transform to use as reference for position & rotation for the transform of the instantiated object", _event.FindPropertyRelative("eventTransform")); break; case CustomEventType.MovePlayerAroundPoint: TDS_EditorUtility.PropertyField("Position", "Where to move te player around", _event.FindPropertyRelative("eventTransform")); break; case CustomEventType.Narrator: TDS_EditorUtility.PropertyField("Quote", "Narrator quote to play", _event.FindPropertyRelative("quote")); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); Color _originalColor = GUI.color; GUI.color = new Color(.7f, .35f, .75f); if (GUILayout.Button(new GUIContent("Load Quote", "Loads the quote with the ID entered as Text ID"), GUILayout.Width(150))) { FieldInfo _fieldInfo = typeof(TDS_Event).GetField("quote", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); if (_fieldInfo != null) { TDS_NarratorQuote _quote = ((TDS_NarratorManager)Resources.Load(TDS_NarratorManager.FILE_PATH)).Quotes.FirstOrDefault(q => q.Name == _event.FindPropertyRelative("quote").FindPropertyRelative("Name").stringValue); if (_quote != null) { TDS_Event[] _objectEvents = (TDS_Event[])typeof(TDS_EventsSystem).GetField(_events.name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).GetValue(target); typeof(TDS_Event).GetField("quote", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).SetValue(_objectEvents[_i], _quote); } } } GUI.color = _originalColor; GUILayout.EndHorizontal(); break; case CustomEventType.PlayMusic: _event.FindPropertyRelative("eventInt").intValue = EditorGUILayout.IntPopup("Music", _event.FindPropertyRelative("eventInt").intValue, Enum.GetNames(typeof(Music)), (int[])Enum.GetValues(typeof(Music))); TDS_EditorUtility.FloatField("Fade Duration", "Time during which the previous music will fade out before the new one starts.", _event.FindPropertyRelative("eventFloat")); break; case CustomEventType.WaitForObjectDeath: TDS_EditorUtility.PropertyField("Object Tag", "Tag waiting for an object with dies", _event.FindPropertyRelative("eventString")); TDS_EditorUtility.PropertyField("Amount", "Amount of object with this tag to wait for death", _event.FindPropertyRelative("eventInt")); break; case CustomEventType.WaitForSpawnAreaDesactivation: TDS_EditorUtility.PropertyField("Amount", "Amount of spawn area to wait for desactivation", _event.FindPropertyRelative("eventInt")); break; case CustomEventType.UnityEventLocal: TDS_EditorUtility.PropertyField("Unity Event", "Associated Unity Event to this event", _event.FindPropertyRelative("unityEvent")); break; case CustomEventType.UnityEventOnline: TDS_EditorUtility.PropertyField("Unity Event", "Associated Unity Event to this event", _event.FindPropertyRelative("unityEvent")); break; case CustomEventType.WaitForAction: TDS_EditorUtility.PropertyField("Action to wait", "Action to wait the player to perform", _event.FindPropertyRelative("actionType")); break; case CustomEventType.WaitForEveryone: TDS_EditorUtility.PropertyField("Bound min X", "Transform to use for minimum bound X value to wait", _event.FindPropertyRelative("eventTransform")); break; default: // Mhmm... break; } // Button to add a new event GUI.color = Color.green; if (TDS_EditorUtility.Button("+", "Add a new event", EditorStyles.miniButton)) { _events.InsertArrayElementAtIndex(_i); bool[] _newFoldouts = new bool[_foldouts.Length + 1]; Array.Copy(_foldouts, 0, _newFoldouts, 0, _i + 1); Array.Copy(_foldouts, _i + 1, _newFoldouts, _i + 2, _foldouts.Length - (_i + 1)); _foldouts = _newFoldouts; } GUI.color = Color.white; } EditorGUILayout.EndVertical(); } }
/// <summary> /// Draws the editor for the editing Character classes. /// </summary> protected void DrawCharacterEditor() { // Make a space at the beginning of the editor GUILayout.Space(10); Color _originalColor = GUI.backgroundColor; GUI.backgroundColor = TDS_EditorUtility.BoxDarkColor; EditorGUILayout.BeginVertical("HelpBox"); // Button to show or not the Character class settings if (TDS_EditorUtility.Button("Character", "Wrap / unwrap Character class settings", TDS_EditorUtility.HeaderStyle)) { IsCharaUnfolded = !isCharaUnfolded; } // If unfolded, draws the custom editor for the Character class if (isCharaUnfolded) { // Records any changements on the editing objects to allow undo Undo.RecordObjects(targets, "Damageable script(s) settings"); // Updates the SerializedProperties to get the latest values serializedObject.Update(); GUI.backgroundColor = TDS_EditorUtility.BoxLightColor; EditorGUILayout.BeginVertical("Box"); // Button to show or not the Character class components if (TDS_EditorUtility.Button("Components & References", "Wrap / unwrap Components & References settings", TDS_EditorUtility.HeaderStyle)) { AreCharaComponentsUnfolded = !areCharaComponentsUnfolded; } // If unfolded, draws the custom editor for the Components & References if (areCharaComponentsUnfolded) { DrawComponentsAndReferences(); } EditorGUILayout.EndVertical(); GUILayout.Space(15); EditorGUILayout.BeginVertical("Box"); // Button to show or not the Character class settings if (TDS_EditorUtility.Button("Settings", "Wrap / unwrap settings", TDS_EditorUtility.HeaderStyle)) { AreCharaSettingsUnfolded = !areCharaSettingsUnfolded; } // If unfolded, draws the custom editor for the settings if (areCharaSettingsUnfolded) { DrawSettings(); } EditorGUILayout.EndVertical(); // If on play mode, draws debugs of the class if (EditorApplication.isPlaying) { GUILayout.Space(15); EditorGUILayout.BeginVertical("Box"); // Button to show or not the Character class debugs if (TDS_EditorUtility.Button("Debugs", "Wrap / unwrap debugs", TDS_EditorUtility.HeaderStyle)) { AreCharaDebugsUnfolded = !areCharaDebugsUnfolded; } // If unfolded, draws the custom editor for the debugs if (areCharaDebugsUnfolded) { DrawDebugs(); } EditorGUILayout.EndVertical(); } // Applies all modified properties on the SerializedObjects serializedObject.ApplyModifiedProperties(); } EditorGUILayout.EndVertical(); GUI.backgroundColor = _originalColor; }
protected virtual void DrawEnemyEditor() { // Button to show or not the enemy class settings if (TDS_EditorUtility.Button(serializedObject.targetObject.name, "Wrap / unwrap Character class settings", TDS_EditorUtility.HeaderStyle)) { IsEnemyUnfolded = !isEnemyUnfolded; } if (isEnemyUnfolded) { // Records any changements on the editing objects to allow undo Undo.RecordObjects(targets, "Damageable script(s) settings"); // Updates the SerializedProperties to get the latest values serializedObject.Update(); if (EditorApplication.isPlaying) { GUILayout.Box($"ENEMY STATE: {(EnemyState)enemyState.enumValueIndex}", TDS_EditorUtility.HeaderStyle); } GUI.backgroundColor = TDS_EditorUtility.BoxLightColor; EditorGUILayout.BeginVertical("Box"); // Button to show or not the Character class components if (TDS_EditorUtility.Button("Components & References", "Wrap / unwrap Components & References settings", TDS_EditorUtility.HeaderStyle)) { AreEnemyComponentsUnfolded = !areEnemyComponentsUnfolded; } // If unfolded, draws the custom editor for the Components & References if (areEnemyComponentsUnfolded) { DrawComponentsAndReferences(); } EditorGUILayout.EndVertical(); GUILayout.Space(15); EditorGUILayout.BeginVertical("Box"); // Button to show or not the Character class settings if (TDS_EditorUtility.Button("Settings", "Wrap / unwrap settings", TDS_EditorUtility.HeaderStyle)) { AreEnemySettingsUnfolded = !areEnemySettingsUnfolded; } // If unfolded, draws the custom editor for the sttings if (areEnemySettingsUnfolded) { DrawSettings(); } EditorGUILayout.EndVertical(); GUILayout.Space(15); EditorGUILayout.BeginVertical("Box"); if (TDS_EditorUtility.Button("Attacks", "Wrap / unwrap attacks class settings", TDS_EditorUtility.HeaderStyle)) { AreEnemyAttacksUnfolded = !areEnemyAttacksUnfolded; } if (areEnemyAttacksUnfolded) { DrawAttacks(); } EditorGUILayout.EndVertical(); // Applies all modified properties on the SerializedObjects serializedObject.ApplyModifiedProperties(); } }