예제 #1
0
        /// <summary>
        /// Draws the details of the category.
        /// </summary>
        /// <param name="rowRect">The rect of the category row.</param>
        /// <param name="id">The id of the category to draw the details of.</param>
        private void DrawDetails(Rect rowRect, int id)
        {
            var rect = rowRect;

            rect.x += 4;
            rect.y += c_RowHeight;
            Shared.Editor.Utility.EditorUtility.RecordUndoDirtyObject(m_ItemCollection, "Category Change");

            var category = m_ItemCollection.Categories[id];

            // Name property.
            var nameRect = rect;

            nameRect.y     += 6;
            nameRect.height = 16;
            nameRect.width -= 16;
            var name = InspectorUtility.DrawEditorWithoutSelectAll(() => InspectorUtility.ClampTextField(nameRect, "Name", category.name, 22));

            // The name must be unique.
            if (name != category.name)
            {
                if (IsUniqueName(name))
                {
                    category.name = name;
                    AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(category));
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Draws the details of the ItemType.
        /// </summary>
        /// <param name="rowRect">The rect of the ItemType row.</param>
        /// <param name="id">The id of the ItemType to draw the details of.</param>
        private void DrawDetails(Rect rowRect, int id)
        {
            var rect = rowRect;

            rect.x += 4;
            rect.y += c_RowHeight;

            var animSet = m_AnimationStateSet.AnimationStates[id];

            Undo.RecordObject(m_AnimationStateSet, "ItemType Change");

            // Name and description properties.
            var nameRect = rect;

            nameRect.y     += 4;
            nameRect.width -= 12;
            nameRect.height = 16;

            // Prevent the label from being far away from the text.
            var name = InspectorUtility.DrawEditorWithoutSelectAll(() => InspectorUtility.ClampTextField(nameRect, "Name", animSet.name, 2));

            if (animSet.name != name)
            {
                if (IsUniqueName(name))
                {
                    animSet.name = name;
                    AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(m_AnimationStateSet));
                }
            }

            // Name and description properties.
            var idRect = rect;

            idRect.y     += 24;
            idRect.width -= 12;
            idRect.height = 16;

            // Prevent the label from being far away from the text.
            var sid    = InspectorUtility.DrawEditorWithoutSelectAll(() => InspectorUtility.ClampTextField(idRect, "ID", "" + animSet.ID, 2));
            int typeId = animSet.ID;

            if (!Int32.TryParse(sid, out typeId))
            {
                typeId = animSet.ID;
            }
            if (animSet.ID != typeId)
            {
                animSet.ID = typeId;
                AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(m_AnimationStateSet));
            }
        }
예제 #3
0
        /// <summary>
        /// Draws the details of the ItemType.
        /// </summary>
        /// <param name="rowRect">The rect of the ItemType row.</param>
        /// <param name="id">The id of the ItemType to draw the details of.</param>
        private void DrawDetails(Rect rowRect, int id)
        {
            var rect = rowRect;

            rect.x += 4;
            rect.y += c_RowHeight;

            var itemType = m_ItemCollection.ItemTypes[id];

            Shared.Editor.Utility.EditorUtility.RecordUndoDirtyObject(itemType, "ItemType Change");

            // Name and description properties.
            var nameRect = rect;

            nameRect.y     += 4;
            nameRect.width -= 12;
            nameRect.height = 16;

            // Prevent the label from being far away from the text.
            var name = InspectorUtility.DrawEditorWithoutSelectAll(() => InspectorUtility.ClampTextField(nameRect, "Name", itemType.name, 2));

            if (itemType.name != name)
            {
                if (IsUniqueName(name))
                {
                    itemType.name = name;
                    AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(m_ItemCollection));
                }
            }

            // Allow for a description of the ItemType.
            var descriptionRect = nameRect;

            descriptionRect.y += descriptionRect.height + 4;
            EditorGUI.LabelField(descriptionRect, "Description");
            descriptionRect.x     += 2;
            descriptionRect.y     += descriptionRect.height + 2;
            descriptionRect.width -= 2;
            descriptionRect.height = 42;
            itemType.Description   = InspectorUtility.DrawEditorWithoutSelectAll(() => EditorGUI.TextArea(descriptionRect, itemType.Description, Shared.Editor.Inspectors.Utility.InspectorStyles.WordWrapTextArea));

            // The ItemType must belong to a category.
            var categoryRect = rect;

            categoryRect.y      = descriptionRect.yMax + 8;
            categoryRect.height = 16;
            categoryRect.width -= 12;

            if (m_ItemCollection.Categories.Length == 0)
            {
                EditorGUI.LabelField(categoryRect, "No categories exist. Categories can be created within the Category tab.");
            }
            else
            {
                var selectedMask  = 0;
                var categoryNames = new string[m_ItemCollection.Categories.Length];
                for (int i = 0; i < categoryNames.Length; ++i)
                {
                    if (m_ItemCollection.Categories[i] == null)
                    {
                        continue;
                    }
                    categoryNames[i] = m_ItemCollection.Categories[i].name;
                    var categoryIDs = m_ItemCollection.ItemTypes[id].CategoryIDs;
                    for (int j = 0; j < categoryIDs.Length; ++j)
                    {
                        if (categoryIDs[j] == m_ItemCollection.Categories[i].ID)
                        {
                            selectedMask |= 1 << i;
                        }
                    }
                }

                var categoryMask = InspectorUtility.ClampMaskField(categoryRect, "Category", selectedMask, categoryNames, 55);
                if (categoryMask != selectedMask)
                {
                    var selectedIDs = new List <uint>();
                    for (int i = 0; i < categoryNames.Length; ++i)
                    {
                        if ((categoryMask & (1 << i)) == (1 << i))
                        {
                            selectedIDs.Add(m_ItemCollection.Categories[i].ID);
                        }
                    }
                    itemType.CategoryIDs = selectedIDs.ToArray();
                }
            }

            // The ItemType can set a max capacity to restrict the item amount.
            var capacityRect = categoryRect;

            capacityRect.y    = capacityRect.yMax + 4;
            itemType.Capacity = InspectorUtility.DrawEditorWithoutSelectAll(() => InspectorUtility.ClampIntField(capacityRect, "Capacity", itemType.Capacity, 59));

            // The ItemType can drop other ItemTypes. Allow for the selection here.
            var nameItemTypeMap = new Dictionary <string, ItemType>();

            for (int i = 0; i < m_ItemCollection.ItemTypes.Length; ++i)
            {
                if (m_ItemCollection.ItemTypes[i] == itemType)
                {
                    continue;
                }
                nameItemTypeMap.Add(m_ItemCollection.ItemTypes[i].name, m_ItemCollection.ItemTypes[i]);
            }
        }