/// <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]); } }