Esempio n. 1
0
        /// <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 GetDrawCallback()
        {
            var baseCallback = base.GetDrawCallback();

            baseCallback += () =>
            {
                InspectorUtility.DrawAttributeModifier(m_AttributeManager, m_Flashlight.BatteryModifier, "Battery Attribute");
            };

            return(baseCallback);
        }
Esempio n. 2
0
        /// <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--;
            }
        }
Esempio n. 3
0
 public override void OnInspectorGUI(object target, Object parent)
 {
     InspectorUtility.DrawAttributeModifier(null, (target as ModifyAttribute).AttributeModifier, "Attribute Modifier");
 }