/// <summary> /// Called when the object should be drawn to the inspector. /// </summary> /// <param name="target">The object that is being drawn.</param> /// <param name="parent">The Unity Object that the object belongs to.</param> public override void OnInspectorGUI(object target, Object parent) { var effectValue = InspectorUtility.GetFieldValue <string>(target, "m_EffectName"); var newEffectValue = InspectorUtility.DrawTypePopup(typeof(UltimateCharacterController.Character.Effects.Effect), effectValue, "Effect", true); if (effectValue != newEffectValue) { InspectorUtility.SetFieldValue(target, "m_EffectName", newEffectValue); InspectorUtility.SetDirty(parent); } InspectorUtility.DrawField(target, "m_EffectIndex"); InspectorUtility.DrawField(target, "m_StopEffect"); }
/// <summary> /// Returns the actions to draw before the State list is drawn. /// </summary> /// <returns>The actions to draw before the State list is drawn.</returns> protected override Action GetHealthDrawCallback() { var baseCallback = base.GetHealthDrawCallback(); baseCallback += () => { if (Foldout("Fall Damage")) { EditorGUI.indentLevel++; var applyFallDamage = PropertyFromName("m_ApplyFallDamage"); EditorGUILayout.PropertyField(applyFallDamage); if (applyFallDamage.boolValue) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(PropertyFromName("m_MinFallDamageHeight")); EditorGUILayout.PropertyField(PropertyFromName("m_MinFallDamage")); EditorGUILayout.PropertyField(PropertyFromName("m_MaxFallDamage")); EditorGUILayout.PropertyField(PropertyFromName("m_DeathHeight")); EditorGUILayout.PropertyField(PropertyFromName("m_DamageCurve")); EditorGUI.indentLevel--; } EditorGUI.indentLevel--; } var damagedEffectValue = PropertyFromName("m_DamagedEffectName").stringValue; var newDamagedEffectValue = InspectorUtility.DrawTypePopup(typeof(UltimateCharacterController.Character.Effects.Effect), damagedEffectValue, "Damaged Effect", true); if (damagedEffectValue != newDamagedEffectValue) { PropertyFromName("m_DamagedEffectName").stringValue = newDamagedEffectValue; Shared.Editor.Utility.EditorUtility.SetDirty(target); } if (!string.IsNullOrEmpty(newDamagedEffectValue)) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(PropertyFromName("m_DamagedEffectIndex")); EditorGUI.indentLevel--; } }; return(baseCallback); }
/// <summary> /// Called when the object should be drawn to the inspector. /// </summary> /// <param name="target">The object that is being drawn.</param> /// <param name="parent">The Unity Object that the object belongs to.</param> public override void OnInspectorGUI(object target, Object parent) { m_Ability = (target as Ability); DrawInputFieldsFields(target, parent); InspectorUtility.DrawAttributeModifier((parent as Component).GetComponent <AttributeManager>(), (target as Ability).AttributeModifier, "Attribute Name"); EditorGUILayout.BeginHorizontal(); InspectorUtility.DrawField(target, "m_State"); GUI.enabled = !string.IsNullOrEmpty(InspectorUtility.GetFieldValue <string>(target, "m_State")); // The InspectorUtility doesn't support a toggle with the text on the right. var field = InspectorUtility.GetField(target, "m_StateAppendItemIdentifierName"); GUILayout.Space(-5); var value = EditorGUILayout.ToggleLeft(new GUIContent("Append Item", InspectorUtility.GetFieldTooltip(field)), (bool)field.GetValue(target), GUILayout.Width(110)); InspectorUtility.SetFieldValue(target, "m_StateAppendItemIdentifierName", value); GUI.enabled = true; EditorGUILayout.EndHorizontal(); InspectorUtility.DrawField(target, "m_AbilityIndexParameter"); DrawInspectorDrawerFields(target, parent); if (InspectorUtility.Foldout(target, "Audio")) { EditorGUI.indentLevel++; if (InspectorUtility.Foldout(target, "Start")) { EditorGUI.indentLevel++; m_ReorderableStartAudioClipsList = AudioClipSetInspector.DrawAudioClipSet(m_Ability.StartAudioClipSet, null, m_ReorderableStartAudioClipsList, OnStartAudioClipDraw, OnStartAudioClipListAdd, OnStartAudioClipListRemove); EditorGUI.indentLevel--; } DrawAudioFields(); if (InspectorUtility.Foldout(target, "Stop")) { EditorGUI.indentLevel++; m_ReorderableStopAudioClipsList = AudioClipSetInspector.DrawAudioClipSet(m_Ability.StopAudioClipSet, null, m_ReorderableStopAudioClipsList, OnStopAudioClipDraw, OnStopAudioClipListAdd, OnStopAudioClipListRemove); EditorGUI.indentLevel--; } EditorGUI.indentLevel--; } var startEffectValue = InspectorUtility.GetFieldValue <string>(target, "m_StartEffectName"); var newStartEffectValue = InspectorUtility.DrawTypePopup(typeof(UltimateCharacterController.Character.Effects.Effect), startEffectValue, "Start Effect", true); if (startEffectValue != newStartEffectValue) { InspectorUtility.SetFieldValue(target, "m_StartEffectName", newStartEffectValue); InspectorUtility.SetDirty(parent); } if (!string.IsNullOrEmpty(newStartEffectValue)) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_StartEffectIndex"); EditorGUI.indentLevel--; } if (InspectorUtility.Foldout(target, "General")) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_InspectorDescription"); GUI.enabled = !(target is MoveTowards); InspectorUtility.DrawField(target, "m_AllowPositionalInput"); InspectorUtility.DrawField(target, "m_AllowRotationalInput"); GUI.enabled = true; InspectorUtility.DrawField(target, "m_UseGravity"); InspectorUtility.DrawField(target, "m_UseRootMotionPosition"); InspectorUtility.DrawField(target, "m_UseRootMotionRotation"); InspectorUtility.DrawField(target, "m_DetectHorizontalCollisions"); InspectorUtility.DrawField(target, "m_DetectVerticalCollisions"); InspectorUtility.DrawField(target, "m_AnimatorMotion"); var itemAbilityMoveTowards = (target is MoveTowards) || (target is UltimateCharacterController.Character.Abilities.Items.ItemAbility); GUI.enabled = !itemAbilityMoveTowards; var inventory = (parent as Component).GetComponent <UltimateCharacterController.Inventory.InventoryBase>(); if (inventory != null && (parent as Component).GetComponent <UltimateCharacterController.Inventory.ItemSetManagerBase>() != null) { var slotCount = inventory.SlotCount; if (InspectorUtility.Foldout(target, "Allow Equipped Items")) { EditorGUI.indentLevel++; var mask = InspectorUtility.GetFieldValue <int>(target, "m_AllowEquippedSlotsMask"); var newMask = 0; for (int i = 0; i < slotCount; ++i) { var enabled = (mask & (1 << i)) == (1 << i); if (EditorGUILayout.Toggle("Slot " + i, enabled)) { newMask |= 1 << i; } } // If all of the slots are enabled then use -1. if (newMask == (1 << slotCount) - 1 || itemAbilityMoveTowards) { newMask = -1; } if (mask != newMask) { InspectorUtility.SetFieldValue(target, "m_AllowEquippedSlotsMask", newMask); } InspectorUtility.DrawField(target, "m_AllowItemDefinitions"); InspectorUtility.DrawField(target, "m_ImmediateUnequip"); InspectorUtility.DrawField(target, "m_ReequipSlots"); if (itemAbilityMoveTowards && InspectorUtility.GetFieldValue <bool>(target, "m_ReequipSlots")) { InspectorUtility.SetFieldValue(target, "m_ReequipSlots", false); GUI.changed = true; } EditorGUI.indentLevel--; } } GUI.enabled = true; EditorGUI.indentLevel--; } if (InspectorUtility.Foldout(target, "UI")) { EditorGUI.indentLevel++; InspectorUtility.DrawField(target, "m_AbilityMessageText"); InspectorUtility.DrawField(target, "m_AbilityMessageIcon"); EditorGUI.indentLevel--; } }