コード例 #1
0
        /// <summary>
        /// Draws the specified item set.
        /// </summary>
        private void DrawSelectedPickupSet(ItemPickupBase.PickupSet pickupSet, int index)
        {
            GUILayout.Label("Pickup Set " + index, Shared.Editor.Inspectors.Utility.InspectorStyles.CenterBoldLabel);

            pickupSet.Item = (GameObject)EditorGUILayout.ObjectField("Item", pickupSet.Item, typeof(GameObject), false);
            if (pickupSet.Item != null)
            {
                // Automatically fill in the ItemDefinition for the specified item.
                var item = pickupSet.Item.GetComponent <Item>();
                if (item != null && item.SlotID < pickupSet.ItemSet.Slots.Length && pickupSet.ItemSet.Slots[item.SlotID] != item.ItemDefinition)
                {
                    pickupSet.ItemSet.Slots[item.SlotID] = item.ItemDefinition;
                    EditorUtility.SetDirty(target);
                }
            }

            GUI.enabled = pickupSet.Item == null && !Application.isPlaying;
            DrawAvailableCategories(pickupSet, new Rect());
            GUI.enabled = !Application.isPlaying;

            pickupSet.ItemSet.State = EditorGUILayout.TextField(new GUIContent("State", "Optionally specify a state that the character should switch to when the Item Set is active."), pickupSet.ItemSet.State);
            // Draws all of the slots ItemIdentifiers.
            for (int i = 0; i < m_SlotCount; ++i)
            {
                pickupSet.ItemSet.Slots[i] = (ItemDefinitionBase)EditorGUILayout.ObjectField("Slot " + i, pickupSet.ItemSet.Slots[i], typeof(ItemDefinitionBase), false);
            }
            pickupSet.Default               = EditorGUILayout.Toggle(new GUIContent("Default", "True if the ItemSet is the default Item Set."), pickupSet.Default);
            pickupSet.ItemSet.Enabled       = EditorGUILayout.Toggle(new GUIContent("Enabled", "True if the ItemSet can be equipped."), pickupSet.ItemSet.Enabled);
            pickupSet.ItemSet.CanSwitchTo   = EditorGUILayout.Toggle(new GUIContent("Can Switch To", "True if the ItemSet can be switched to by the EquipNext/EquipPrevious abilities."), pickupSet.ItemSet.CanSwitchTo);
            pickupSet.ItemSet.DisabledIndex = EditorGUILayout.IntField(new GUIContent("Disabled Index", "The ItemSet that should be activated if the current ItemSet is disabled."), pickupSet.ItemSet.DisabledIndex);

            if (Shared.Editor.Inspectors.Utility.InspectorUtility.Foldout(pickupSet, new GUIContent("States"), false))
            {
                // The MovementType class derives from system.object at the base level and reorderable lists can only operate on Unity objects. To get around this restriction
                // create a dummy array within a Unity object that corresponds to the number of elements within the ability's state list. When the reorderable list is drawn
                // the ability object will be used so it's like the dummy object never existed.
                var gameObject = new GameObject();
                try {
                    var stateIndexHelper = gameObject.AddComponent <StateInspectorHelper>();
                    stateIndexHelper.StateIndexData = new int[pickupSet.ItemSet.States.Length];
                    for (int i = 0; i < stateIndexHelper.StateIndexData.Length; ++i)
                    {
                        stateIndexHelper.StateIndexData[i] = i;
                    }
                    var stateIndexSerializedObject = new SerializedObject(stateIndexHelper);
                    m_ReorderablePickupSetStateList = StateInspector.DrawStates(m_ReorderablePickupSetStateList, serializedObject,
                                                                                stateIndexSerializedObject.FindProperty("m_StateIndexData"),
                                                                                GetSelectedPickupSetStateIndexKey(index), OnPickupSetStateListDraw, OnPickupSetStateListAdd,
                                                                                OnPickupSetStateListReorder, OnPickupSetStateListRemove);
                } catch (System.Exception /*e*/) { }
                DestroyImmediate(gameObject);
            }
        }
コード例 #2
0
        /// <summary>
        /// Draws the field that displays the available categories.
        /// </summary>
        /// <param name="pickupSet">The PickupSet that should be drawn.</param>
        /// <param name="objRect">The location the categories should draw.</param>
        protected override void DrawAvailableCategories(ItemPickupBase.PickupSet pickupSet, Rect objRect)
        {
            var categoryNames = new string[((m_ItemCollection != null && m_ItemCollection.Categories != null) ? m_ItemCollection.Categories.Length : 0) + 1];

            categoryNames[0] = "(Not Specified)";
            var selected = -1;

            if (categoryNames.Length > 1 && GUI.enabled)
            {
                for (int i = 0; i < m_ItemCollection.Categories.Length; ++i)
                {
                    categoryNames[i + 1] = m_ItemCollection.Categories[i].name;
                    if (pickupSet.CategoryID == m_ItemCollection.Categories[i].ID)
                    {
                        selected = i;
                    }
                }
            }
            int newSelected;

            if (objRect.width == 0)
            {
                newSelected = EditorGUILayout.Popup("Category", selected != -1 ? selected : 0, categoryNames);
            }
            else
            {
                newSelected = EditorGUI.Popup(objRect, selected != -1 ? selected : 0, categoryNames);
            }
            if (selected != newSelected)
            {
                if (newSelected == 0)
                {
                    pickupSet.CategoryID = 0;
                }
                else
                {
                    pickupSet.CategoryID = m_ItemCollection.Categories[newSelected - 1].ID;
                }
                GUI.changed = true;
            }
        }
コード例 #3
0
 /// <summary>
 /// Draws the field that displays the available categories.
 /// </summary>
 /// <param name="pickupSet">The PickupSet that should be drawn.</param>
 /// <param name="objRect">The location the categories should draw.</param>
 protected abstract void DrawAvailableCategories(ItemPickupBase.PickupSet pickupSet, Rect objRect);