/// <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> /// Draws the editor for the Character class components & references. /// </summary> private void DrawComponentsAndReferences() { // If playing, display editor for the health bar & the throwable if (EditorApplication.isPlaying) { TDS_EditorUtility.ObjectField("Health Bar", "HitBox of this character, used to detect what they touch when attacking", healthBar, typeof(UnityEngine.UI.Image)); GUILayout.Space(3); if (!targets.Any(t => t is TDS_Juggler) && TDS_EditorUtility.ObjectField("Throwable", "Throwable this character is actually wearing", throwable, typeof(TDS_Throwable))) { { characters.ForEach(c => c.GrabObject((TDS_Throwable)throwable.objectReferenceValue)); serializedObject.Update(); } } GUILayout.Space(5); } TDS_EditorUtility.ObjectField("Hit Box", "HitBox of this character, used to detect what they touch when attacking", hitBox, typeof(TDS_HitBox)); TDS_EditorUtility.ObjectField("Hands Transform", "Transform at the position of the character hands ; mainly used as root for carrying throwable", handsTransform, typeof(Transform)); TDS_EditorUtility.ObjectField("Shadow Transform", "Transform of the character's shadow", shadowTransform, typeof(Transform)); GUILayout.Space(3); }
/// <summary> /// Draws the custom editor for the components & references of this class. /// </summary> private void DrawComponentsAndReferences() { if (EditorApplication.isPlaying) { TDS_EditorUtility.PropertyField("Throwables in Hands", "All throwables currently juggling with", throwables); GUILayout.Space(5); if (TDS_EditorUtility.ObjectField("Selected Throwable", "Currently selected throwable to use", throwable, typeof(TDS_Throwable))) { jugglers.ForEach(j => j.Throwable = (TDS_Throwable)throwable.objectReferenceValue); serializedObject.Update(); } GUILayout.Space(5); } GUILayout.Space(5); TDS_EditorUtility.ObjectField("Juggle Transform", "Juggle transform, where to set as children objects juggling with", juggleTransform, typeof(Transform)); GUILayout.Space(3); TDS_EditorUtility.PropertyField("Object Anchors", "Object anchors when juggling", objectAnchors); }
/// <summary> /// Draws the custom editor for this class settings. /// </summary> private void DrawSettings() { if (Application.isPlaying) { Color _originalColor = GUI.color; GUI.color = !isDrunk.boolValue ? new Color(.8f, .25f, .25f) : new Color(.25f, .8f, .25f); EditorGUILayout.BeginHorizontal(); GUILayout.Space(15); if (GUILayout.Button(!isDrunk.boolValue ? new GUIContent("Get Drunk", "Get the Fire Eater drunk") : new GUIContent("Get Sober", "Make the Fire Eater sober again"), GUILayout.Width(100), GUILayout.Height(20))) { foreach (TDS_FireEater _fireEater in fireEaters) { if (_fireEater.ComboCurrent.Count > 0) { _fireEater.BreakCombo(); } if (!isDrunk.boolValue) { _fireEater.GetDrunk(); } else { soberUpTimer.floatValue = 0; } } } EditorGUILayout.EndHorizontal(); GUI.color = _originalColor; GUILayout.Space(10); } if (TDS_EditorUtility.FloatField("Sober Up Time", "Time it takes to the Fire Eater to sober up (in seconds)", soberUpTime)) { fireEaters.ForEach(f => f.SoberUpTime = soberUpTime.floatValue); serializedObject.Update(); } if (TDS_EditorUtility.FloatField("Drunk Speed Coef", "Coefficient applied to speed when drunk", drunkSpeedCoef)) { fireEaters.ForEach(f => f.DrunkSpeedCoef = drunkSpeedCoef.floatValue); serializedObject.Update(); } TDS_EditorUtility.FloatField("X Mov. after Drunken Dodge", "Distance to move the Fire Eater before getting up after a drunken dodge", xMovementAfterDrunkenDodge); if (TDS_EditorUtility.IntField("Drunk Jump Force", "Force applied when performing a jump when drunk", drunkJumpForce)) { fireEaters.ForEach(f => f.DrunkJumpForce = drunkJumpForce.intValue); serializedObject.Update(); } GUILayout.Space(3); }
/// <summary> /// Draws the editor for Damageable class components & references /// </summary> private void DrawComponentsAndReferences() { TDS_EditorUtility.ObjectField("Animator", "Animator of this object", animator, typeof(Animator)); TDS_EditorUtility.ObjectField("Collider", "Non-trigger BoxCollider of this object, used to detect collisions", collider, typeof(BoxCollider)); TDS_EditorUtility.ObjectField("Rigidbody", "Rigidbody of this character, used for physic simulation", rigidbody, typeof(Rigidbody)); TDS_EditorUtility.ObjectField("Sprite", "Main SpriteRenderer used to render this object", sprite, typeof(SpriteRenderer)); GUILayout.Space(3); }
/// <summary> /// Draws the debugs editor of the TDS_Player editing objects. /// </summary> private void DrawDebugs() { TDS_EditorUtility.RadioToggle("Grounded", "Is this player on ground or not", isGrounded); TDS_EditorUtility.RadioToggle("Moving", "Is this player currently moving or not", isMoving); TDS_EditorUtility.RadioToggle("Jumping", "Is this player currently jumping or not", isJumping); TDS_EditorUtility.RadioToggle("Dodging", "Is this player currently dodging or not", isDodging); TDS_EditorUtility.RadioToggle("Preparing Attack", "Is this player currently preparing an attack", isPreparingAttack); TDS_EditorUtility.RadioToggle("Parrying", "Is this player currently parrying or not", isParrying); }
/* TDS_SpawningInformationsEditor : * * ##################### * ###### PURPOSE ###### * ##################### * * Editor of the Random Spawning Information class * * ##################### * ### MODIFICATIONS ### * ##################### * * Date : [12/02/2019] * Author : [THIEBAUT Alexis] * * Changes : * * [Initialisation de la class] * - Implémentation de la methode OnGUI pour afficher les settings de la Random Spawning Information * ----------------------------------- */ #region Methods public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { base.OnGUI(position, property, label); // Display the chance of spawn for the random enemies if (property.FindPropertyRelative("isFoldOut").boolValue) { TDS_EditorUtility.IntSlider("Spawn Chance", "", property.FindPropertyRelative("spawnChance"), 1, 100); } }
private void DrawAttacks() { EditorGUILayout.BeginVertical("Box"); //Draw a header for the enemy evolution settings EditorGUILayout.LabelField("Attack Settings", TDS_EditorUtility.HeaderStyle); TDS_EditorUtility.PropertyField("Attacks", "", attacks); EditorGUILayout.EndVertical(); }
/// <summary> /// Draws the debugs editor of the TDS_Juggler editing objects. /// </summary> private void DrawDebugs() { GUILayout.Space(5); TDS_EditorUtility.ProgressBar(25, growBeardTimer.floatValue / beardGrowInterval.floatValue, "Beard Grow Progress"); GUILayout.Space(10); TDS_EditorUtility.ProgressBar(25, healBeardTimer.floatValue / beardHealInterval.floatValue, "Beard Heal Progress"); GUILayout.Space(5); }
/// <summary> /// Draws the components & references editor of the TDS_Player editing objects. /// </summary> private void DrawComponentsAndReferences() { TDS_EditorUtility.PropertyField("Ground detection Box", "Virtual box used to detect if the player is on ground or not", groundDetectionBox); GUILayout.Space(5); TDS_EditorUtility.ObjectField("Interaction Box", "Trigger used to detect the available interactions of the player", interactionBox, typeof(TDS_PlayerInteractionBox)); TDS_EditorUtility.ObjectField("FX Transform", "Transform used to spawn all kind of FXs", fxTransformPV, typeof(PhotonView)); TDS_EditorUtility.ObjectField("Summoner object", "The Summoner the player is actually wearing", summoner, typeof(TDS_Summoner)); }
/// <summary> /// Draws the editor of the editing scripts. /// </summary> public override void DrawEditor() { // Make a space at the beginning of the editor GUILayout.Space(10); Color _originalColor = GUI.backgroundColor; Color _originalGUIColor = GUI.color; GUI.backgroundColor = TDS_EditorUtility.BoxDarkColor; EditorGUILayout.BeginVertical("HelpBox"); // Records any changements on the editing objects to allow undo Undo.RecordObjects(targets, "Event System settings"); // Updates the SerializedProperties to get the latest values serializedObject.Update(); GUILayout.Space(3); TDS_EditorUtility.RadioToggle("Activated", "Is this event system activated or not", isActivated); if (isActivated.boolValue) { GUILayout.Space(3); EditorGUILayout.LabelField(new GUIContent("Current Event", "Current event processing"), new GUIContent(currentEvent.FindPropertyRelative("Name").stringValue)); } GUILayout.Space(5); TDS_EditorUtility.Toggle("Des. Object when Finished", "Should this object be deactivated when the event system gets finished", doDesObjectOnFinish); GUILayout.Space(3); GUI.backgroundColor = _originalColor; TDS_EditorUtility.PropertyField("Detected Tags", "Tags detected to trigger this event", detectedTags); GUI.backgroundColor = TDS_EditorUtility.BoxDarkColor; GUILayout.Space(5); // Draws enter events EditorGUILayout.LabelField("Enter Events"); DrawEvents(events, ref foldouts); GUILayout.Space(5); // Draws exit events EditorGUILayout.LabelField("Exit Events"); DrawEvents(exitEvents, ref exitFoldouts); // Applies all modified properties on the SerializedObjects serializedObject.ApplyModifiedProperties(); EditorGUILayout.EndVertical(); GUI.backgroundColor = _originalColor; GUI.color = _originalGUIColor; }
protected override void DrawSettings() { base.DrawSettings(); EditorGUILayout.LabelField("Evolve", TDS_EditorUtility.HeaderStyle); TDS_EditorUtility.RadioToggle("Has Evolved", "Is the minion evolved", hasEvolved); GUILayout.Space(5); EditorGUILayout.LabelField("Rage", TDS_EditorUtility.HeaderStyle); TDS_EditorUtility.FloatField("Reset Rage Delay", "Delay to reset the rage", resetRageDelay); TDS_EditorUtility.IntSlider("Reset Rage Threshold", "Count of attacks to ignore the next damages", ragingThreshold, 1, 5); }
void DrawSpawnedEnemies() { EditorGUILayout.BeginVertical("Helpbox"); EditorGUILayout.LabelField("Spawned Elements", TDS_EditorUtility.HeaderStyle); GUILayout.Space(5); TDS_EditorUtility.PropertyField("Spawned Enemies", "Enemies already on the scene in editor", spawnedEnemies); GUILayout.Space(3); TDS_EditorUtility.PropertyField("Linked Throwables", "Throwables linked to this spawn area", areaThrowables); EditorGUILayout.EndVertical(); GUILayout.Space(15); }
/// <summary> /// Draws the custom editor for the debugs of this class. /// </summary> private void DrawDebugs() { GUILayout.Space(5); TDS_EditorUtility.RadioToggle("Drunk", "Indicates if the Fire Eater is drunk", isDrunk); GUILayout.Space(5); if (isDrunk.boolValue) { TDS_EditorUtility.ProgressBar(25, soberUpTimer.floatValue / soberUpTime.floatValue, "Drunk"); GUILayout.Space(5); } }
private void DrawCatSettings() { EditorGUILayout.LabelField(serializedObject.targetObject.name, TDS_EditorUtility.HeaderStyle); TDS_EditorUtility.PropertyField("Cat State", "On which perch the cat is", catState); TDS_EditorUtility.PropertyField("Left Perch Infos", "Left perch infos", leftPerchInfos); TDS_EditorUtility.PropertyField("Right Perch Infos", "Left perch infos", rightPerchInfos); TDS_EditorUtility.PropertyField("Cat Attack", "Attack casted by the cat", catAttack); TDS_EditorUtility.FloatSlider("Charge Rate", "Rate using when the cat is independant", chargeRate, 5, 25); serializedObject.ApplyModifiedProperties(); }
private void DrawEvents() { Color _originalColor = GUI.backgroundColor; GUI.backgroundColor = new Color(.8f, .8f, .8f); TDS_EditorUtility.PropertyField("On Spawn Area Activated", "Called when a player activate the trigger", eventOnAreaActivated); TDS_EditorUtility.PropertyField("On Fight Start", "Called when the fight is starting", eventOnStartFight); TDS_EditorUtility.PropertyField("On Spawn Area Desactivated", "Called when all waves are completed", eventOnAreaDesactivated); TDS_EditorUtility.PropertyField("On Next Wave", "Called when a wave is completed", eventOnNextWave); GUI.backgroundColor = _originalColor; }
/// <summary> /// Draws the editor for the Destructible class settings. /// </summary> protected void DrawSettings() { TDS_EditorUtility.IntSlider("Loot Chance", "Chance in percentage to have drop on this destructible destruction", lootChance, 0, 100); GUILayout.Space(3); TDS_EditorUtility.IntSlider("Min Loot", "Minimum amount of loot for this destructible", lootMin, 0, lootMax.intValue); if (TDS_EditorUtility.IntField("Max Loot", "Maximum amount of loot for this destructible", lootMax)) { destructibles.ForEach(d => d.LootMax = lootMax.intValue); serializedObject.Update(); } }
protected override void DrawSettings() { base.DrawSettings(); TDS_EditorUtility.IntSlider("Damages Threshold", "How much damages had to be taken to play the hit animation", damagesThreshold, 1, 50); TDS_EditorUtility.ObjectField("Boss Portrait", "Portrait to display next to the boss' lifebar", portrait, typeof(GameObject)); EditorGUILayout.LabelField("Health events", TDS_EditorUtility.HeaderStyle); TDS_EditorUtility.PropertyField("On Two Thirds Health", "Event called when the boss has reached two thirds of his life", onTwoThirdsHealth); TDS_EditorUtility.PropertyField("On Half Health", "Event called when the boss has reached half of his life", onHalfHealth); TDS_EditorUtility.PropertyField("On One Third Health", "Event called when the boss has reached one third of his life", onOneThirdHealth); }
/// <summary> /// Draws the custom editor for this class settings. /// </summary> private void DrawSettings() { if (Application.isPlaying) { if (TDS_EditorUtility.Toggle("Angry", "Indicates if the Fat Lady is in Angry or in \"Cool\" mode", isAngry)) { fatLadies.ForEach(f => f.IsAngry = isAngry.boolValue); serializedObject.Update(); } GUILayout.Space(5); } if (TDS_EditorUtility.FloatField("Angry Speed Coef", "Coefficient applied to the Fat Lady's speed when angry", angrySpeedCoef)) { fatLadies.ForEach(f => f.AngrySpeedCoef = angrySpeedCoef.floatValue); serializedObject.Update(); } if (TDS_EditorUtility.IntField("Angry Health Step", "Health value separating the Angry mode and the Cool one", angryHealthStep)) { fatLadies.ForEach(f => f.AngryHealthStep = angryHealthStep.intValue); serializedObject.Update(); } GUILayout.Space(3); if (Application.isPlaying) { if (TDS_EditorUtility.Toggle("Snack Available", "Indicates if the Fat Lady's snack is available for use", isSnackAvailable)) { fatLadies.ForEach(f => f.IsSnackAvailable = isSnackAvailable.boolValue); serializedObject.Update(); } GUILayout.Space(3); TDS_EditorUtility.ProgressBar(25, isSnackAvailable.boolValue ? 0 : snackRestaureTimer.floatValue / snackRestaureTime.floatValue, "Snack Restauration"); GUILayout.Space(3); } if (TDS_EditorUtility.FloatField("Snack Restaure Time", "Time i takes to restaure the snack after eating (in seconds)", snackRestaureTime)) { fatLadies.ForEach(f => f.SnackRestaureTime = snackRestaureTime.floatValue); serializedObject.Update(); } if (TDS_EditorUtility.IntField("Snack Heal Value", "Heal value when snacking", snackHealValue)) { fatLadies.ForEach(f => f.SnackHealValue = snackHealValue.intValue); serializedObject.Update(); } }
/// <summary> /// Draws the custom editor for this class settings. /// </summary> private void DrawSettings() { if (TDS_EditorUtility.FloatField("Juggle Speed", "Speed at which the Juggler juggle with his objects", juggleSpeed)) { jugglers.ForEach(j => j.JuggleSpeed = juggleSpeed.floatValue); serializedObject.Update(); } if (TDS_EditorUtility.FloatField("Throw. Dist. from Center", "Distance of each throwables from the hands transform of the character", throwableDistanceFromCenter)) { jugglers.ForEach(j => j.ThrowableDistanceFromCenter = throwableDistanceFromCenter.floatValue); serializedObject.Update(); } GUILayout.Space(5); TDS_EditorUtility.Vector3Field("Juggle Transf. Ideal Pos.", "Position the juggle transform is always looking to have (in local space)", juggleTransformIdealLocalPosition); // Draws a header for the juggler aim settings EditorGUILayout.LabelField("Aim", TDS_EditorUtility.HeaderStyle); GUILayout.Space(3); TDS_EditorUtility.PropertyField("What Can Aim", "Indicates what the player can aim at", whatCanAim); TDS_EditorUtility.PropertyField("Aim Detected Tags", "Detected tags as target when freely aiming", aimDetectTags); GUILayout.Space(2); if (TDS_EditorUtility.FloatSlider("Aiming Speed Coef", "Speed coefficient applied to the character while he's aiming", aimingSpeedCoef, 0f, 2f)) { jugglers.ForEach(j => j.AimingSpeedCoef = aimingSpeedCoef.floatValue); serializedObject.Update(); } if (TDS_EditorUtility.FloatField("Time between Shoots", "Minimum time to spend between two object shoots", timeBetweenShoots)) { jugglers.ForEach(j => j.TimeBetweenShoots = timeBetweenShoots.floatValue); serializedObject.Update(); } if (EditorApplication.isPlaying) { if (TDS_EditorUtility.FloatSlider("Aiming Angle", "Angle used by the Juggler to aim for a throw", aimAngle, 15f, 60f)) { jugglers.ForEach(j => j.AimAngle = aimAngle.floatValue); serializedObject.Update(); } TDS_EditorUtility.Vector3Field("Throw Aiming Point", "Position to aim when preparing a throw (in local space)", throwAimingPoint); } }
/// <summary> /// Draws the editor for Damageable class settings /// </summary> private void DrawSettings() { // If the serializedProperty is changed, triggers the property of the field // After the property has been used, update the object so that serializedProperties can be refresh if (TDS_EditorUtility.IntSlider("Health", "Current health of this object", healthCurrent, 0, healthMax.intValue)) { damageables.ForEach(d => d.HealthCurrent = healthCurrent.intValue); serializedObject.Update(); } if (!healthCurrent.hasMultipleDifferentValues) { GUILayout.Space(5); TDS_EditorUtility.ProgressBar(25, (float)healthCurrent.intValue / healthMax.intValue, "Health"); GUILayout.Space(5); } // If the application is playing, draws two button next to each other allowing the heal & damage the object if (EditorApplication.isPlaying) { DrawLifeButtons(); } if (TDS_EditorUtility.IntField("Max Health", "Maximum health of the object ; its health cannot exceed this value", healthMax)) { damageables.ForEach(d => d.HealthMax = healthMax.intValue); serializedObject.Update(); } if (TDS_EditorUtility.Toggle("Dead", "Indicates if the object is dead, or not", isDead)) { damageables.ForEach(d => d.IsDead = isDead.boolValue); serializedObject.Update(); } if (TDS_EditorUtility.Toggle("Indestructible", "When indestructible, the object will not be dead when its health reach zero", isIndestructible)) { damageables.ForEach(d => d.IsIndestructible = isIndestructible.boolValue); serializedObject.Update(); } TDS_EditorUtility.Toggle("Invulnerable", "When invulnerable, the object cannot take any damage", isInvulnerable); TDS_EditorUtility.Toggle("Can be Moved", "If set to true, this damageable can suffer the effects of special attack effect moving opponent", canBeMoved); GUILayout.Space(3); }
/// <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 custom editor for this class settings. /// </summary> private void DrawSettings() { if (TDS_EditorUtility.PropertyField("Beard State", "Current state of the Beard Lady's beard", currentBeardState) && Application.isPlaying) { beardLadies.ForEach(b => b.CancelInvokeGrowBeard()); beardLadies.ForEach(b => b.CurrentBeardState = (BeardState)currentBeardState.enumValueIndex); serializedObject.Update(); } GUILayout.Space(3); TDS_EditorUtility.ProgressBar(25, (float)currentBeardState.enumValueIndex / 3, "Beard State"); GUILayout.Space(5); if (TDS_EditorUtility.FloatField("Beard Grow Interval", "Interval between two beard grow up", beardGrowInterval)) { beardLadies.ForEach(b => b.BeardGrowInterval = beardGrowInterval.floatValue); serializedObject.Update(); } if (TDS_EditorUtility.IntSlider("Beard Life", "Current beard life", beardCurrentLife, 0, beardMaxLife.intValue) && Application.isPlaying) { beardLadies.ForEach(b => b.BeardCurrentLife = beardCurrentLife.intValue); serializedObject.Update(); } GUILayout.Space(3); TDS_EditorUtility.ProgressBar(25, (float)beardCurrentLife.intValue / beardMaxLife.intValue, "Beard Life"); GUILayout.Space(5); if (TDS_EditorUtility.IntField("Beard Max Life", "Maximum beard life value", beardMaxLife)) { beardLadies.ForEach(b => b.BeardMaxLife = beardMaxLife.intValue); serializedObject.Update(); } if (TDS_EditorUtility.FloatField("Beard Heal Interval", "Interval between two beard heal", beardHealInterval)) { beardLadies.ForEach(b => b.BeardHealInterval = beardHealInterval.floatValue); serializedObject.Update(); } }
protected override void DrawSettings() { base.DrawSettings(); TDS_EditorUtility.PropertyField("Area activated by Mr Loyal", "Area used in the top phase of Mr Loyal", linkedAreas); TDS_EditorUtility.PropertyField("Cats", "Mr Loyal's cats", cats); TDS_EditorUtility.FloatSlider("Cats' charge rate", "Waiting seconds before the cats will attack", chargeCatsRate, 5, 25); TDS_EditorUtility.Vector3Field("Teleportation Position", "Position where Mr Loyal's will teleport himself", teleportationPosition); EditorGUILayout.LabelField("SOUNDS", TDS_EditorUtility.HeaderStyle); TDS_EditorUtility.PropertyField("Callout Fakir Sound", "", fakirAudioClip); TDS_EditorUtility.PropertyField("Callout Mime Sound", "", mimeAudioClip); TDS_EditorUtility.PropertyField("Callout Acrobat Sound", "", acrobatAudioClip); TDS_EditorUtility.PropertyField("Callout MightyMan Sound", "", mightyManAudioClip); TDS_EditorUtility.PropertyField("Callout Cat Sound", "", catAudioClip); TDS_EditorUtility.PropertyField("Taunt audio clips", "", tauntAudioClips); TDS_EditorUtility.FloatSlider("Main Taunt rate", "", tauntRateMin, 3, tauntRateMax.floatValue); TDS_EditorUtility.FloatSlider("Max Taunt rate", "", tauntRateMax, tauntRateMin.floatValue, 25); serializedObject.ApplyModifiedProperties(); }
/// <summary> /// Draw the editor for the variables settings of the enemy /// </summary> protected virtual void DrawSettings() { // Draw a header for the enemy detection settings EditorGUILayout.LabelField("Detection", TDS_EditorUtility.HeaderStyle); TDS_EditorUtility.FloatSlider("Wandering range Min", "The wandering distance around the targeted player when other enemies attacking an enemy", wanderingRangeMin, 1, wanderingRangeMax.floatValue); TDS_EditorUtility.FloatSlider("Wandering range Max", "The wandering distance around the targeted player when other enemies attacking an enemy", wanderingRangeMax, wanderingRangeMin.floatValue, 10); TDS_EditorUtility.FloatSlider("Taunt Probability", "The chance to taunt after wandering", tauntProbability, 0, 100); GUILayout.Space(3); //Draw a header for the enemy scale up settings EditorGUILayout.LabelField("Scale Up Settings", TDS_EditorUtility.HeaderStyle); TDS_EditorUtility.Toggle("Scale Up", "Should this enemy health scale up depending on player amount", doScaleOnPlayerAmount); if (doScaleOnPlayerAmount.boolValue) { if (TDS_EditorUtility.IntSlider("Health Scale Up Percent", "Percentage by which this enemy health is scaled up for each other player", healthScalePercent, 0, 100)) { enemies.ForEach(e => e.HealthScalePercent = healthScalePercent.intValue); serializedObject.Update(); } } GUILayout.Space(3); //Draw a header for the enemy down settings EditorGUILayout.LabelField("Damages Settings", TDS_EditorUtility.HeaderStyle); TDS_EditorUtility.Toggle("Can be grounded", "Is the enemy can be grounded", canBeDown); GUILayout.Space(3); // Draws a header for the enemy attacks settings TDS_EditorUtility.Toggle("Can Throw", "Is the enemy can throw objects", canThrow); if (canThrow.boolValue) { TDS_EditorUtility.FloatSlider("Throw Range", "Distance reached by the throwed object", throwRange, .5f, 20f); } GUILayout.Space(3); }
/// <summary> /// Draws the editor of the editing scripts. /// </summary> public virtual void DrawEditor() { // Make a space at the beginning of the editor GUILayout.Space(10); Color _originalColor = GUI.backgroundColor; Color _originalGUIColor = GUI.color; GUI.backgroundColor = TDS_EditorUtility.BoxDarkColor; EditorGUILayout.BeginVertical("HelpBox"); // Records any changements on the editing objects to allow undo Undo.RecordObjects(targets, "Event System settings"); // Updates the SerializedProperties to get the latest values serializedObject.Update(); GUILayout.Space(3); TDS_EditorUtility.RadioToggle("Activated", "Is this event system activated or not", isActivated); if (isActivated.boolValue) { GUILayout.Space(3); EditorGUILayout.LabelField(new GUIContent("Current Event", "Current event processing"), new GUIContent(currentEvent.FindPropertyRelative("Name").stringValue)); } GUILayout.Space(5); TDS_EditorUtility.Toggle("Local", "Is this event system local-based or online ?", isLocal); GUILayout.Space(2); TDS_EditorUtility.Toggle("Des. Collider on Activation", "Should this object collider be desactivated when starting events", doDesTriggerOnActiv); TDS_EditorUtility.Toggle("Looping", "Should this event system loop when reaching the end or not", doLoop); TDS_EditorUtility.Toggle("Des. Object when Finished", "Should this object be deactivated when the event system gets finished", doDesObjectOnFinish); GUILayout.Space(2); TDS_EditorUtility.PropertyField("Activation mode", "Activation mode used to trigger these events", activationMode); if (activationMode.enumValueIndex < 3) { GUILayout.Space(3); GUI.backgroundColor = _originalColor; TDS_EditorUtility.PropertyField("Detected Tags", "Tags detected to trigger this event", detectedTags); GUI.backgroundColor = TDS_EditorUtility.BoxDarkColor; } GUILayout.Space(5); // Draws events DrawEvents(events, ref foldouts); // Applies all modified properties on the SerializedObjects serializedObject.ApplyModifiedProperties(); EditorGUILayout.EndVertical(); GUI.backgroundColor = _originalColor; GUI.color = _originalGUIColor; }
/// <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 Character class settings. /// </summary> private void DrawSettings() { // Draws a header for the character behaviour settings EditorGUILayout.LabelField("Behaviour", TDS_EditorUtility.HeaderStyle); GUILayout.Space(3); TDS_EditorUtility.Toggle("Pacific", "When pacific, the character will not attack", isPacific); TDS_EditorUtility.Toggle("Paralyzed", "When paralyzed, the character will no move", isParalyzed); // When on play and setting the toggle, do not change the property but execute the Flip method instead if (EditorApplication.isPlaying) { if (!isCharaMultiEditing && TDS_EditorUtility.Toggle("Facing Right Side", "Indicates if the character is currently facing the right side of the screen, or not", isFacingRight, false)) { characters[0].Flip(); serializedObject.Update(); } } else { TDS_EditorUtility.Toggle("Facing Right Side", "Indicates if the character is currently facing the right side of the screen, or not", isFacingRight); } // Draws a header for the character behaviour settings EditorGUILayout.LabelField("Speed", TDS_EditorUtility.HeaderStyle); GUILayout.Space(3); // When on play and not multi editing, diplay a progress bar representing the current speed of the character if (EditorApplication.isPlaying) { if (!isCharaMultiEditing) { TDS_EditorUtility.ProgressBar(20, speedCurrent.floatValue / speedMax.floatValue, "Speed"); GUILayout.Space(5); } } // If the serializedProperty is changed, triggers the property of the field // After the property has been used, update the object so that serializedProperties can be refresh if (TDS_EditorUtility.FloatSlider("Initial Speed", "Speed of the character when starting moving", speedInitial, 0, speedMax.floatValue)) { characters.ForEach(c => c.SpeedInitial = speedInitial.floatValue); serializedObject.Update(); } if (TDS_EditorUtility.FloatField("Max Speed", "Maximum speed of the character", speedMax)) { characters.ForEach(c => c.SpeedMax = speedMax.floatValue); serializedObject.Update(); } if (TDS_EditorUtility.FloatField("Speed Acceleration Time", "Time that take the character to get its speed to the maximum value, after starting moving (in seconds)", speedAccelerationTime)) { characters.ForEach(c => c.SpeedAccelerationTime = speedAccelerationTime.floatValue); serializedObject.Update(); } if (TDS_EditorUtility.FloatField("Speed Coefficient", "Global coefficient used to multiply all speed values for this character", speedCoef)) { characters.ForEach(c => c.SpeedCoef = speedCoef.floatValue); serializedObject.Update(); } if (!EditorApplication.isPlaying) { // Draws a header for the player aim settings EditorGUILayout.LabelField("Throwables & Aiming", TDS_EditorUtility.HeaderStyle); GUILayout.Space(3); if (TDS_EditorUtility.IntField("Throw max. Bonus Damages", "Maximum amount of bonus damages when throwing an object", throwBonusDamagesMax)) { characters.ForEach(p => p.ThrowBonusDamagesMax = throwBonusDamagesMax.intValue); serializedObject.Update(); } if (TDS_EditorUtility.IntSlider("Throw min. Bonus Damages", "Minimum amount of bonus damages when throwing an object", throwBonusDamagesMin, 0, throwBonusDamagesMax.intValue)) { characters.ForEach(p => p.ThrowBonusDamagesMin = throwBonusDamagesMin.intValue); serializedObject.Update(); } GUILayout.Space(3); if (TDS_EditorUtility.FloatSlider("Aiming Angle", "Angle used by this player to aim for a throw", aimAngle, 15f, 60f)) { characters.ForEach(p => p.AimAngle = aimAngle.floatValue); serializedObject.Update(); } TDS_EditorUtility.Vector3Field("Throw Aiming Point", "Position to aim when preparing a throw (Local space)", throwAimingPoint); } GUILayout.Space(3); }
/// <summary> /// Draws the editor for the Character class debug elements. /// </summary> private void DrawDebugs() { GUILayout.Space(3); TDS_EditorUtility.RadioToggle("Attacking", "Is this character currently attacking or not", isAttacking); }