Ejemplo n.º 1
0
        private void On_SelectedItem(ReorderableList list)
        {
            if (m_ItemList == null || m_ItemList.count == 0 || m_ItemList.index == -1 || m_ItemList.index >= m_ItemList.count)
            {
                return;
            }

            m_ItemNames     = ItemManagementUtility.GetItemNames(m_CategoryList.serializedProperty);
            m_ItemNamesFull = ItemManagementUtility.GetItemNamesFull(m_CategoryList.serializedProperty);

            m_CurItemDescriptions = new ReorderableList(m_ItemDatabase, m_ItemList.serializedProperty.GetArrayElementAtIndex(m_ItemList.index).FindPropertyRelative("m_Descriptions"), true, true, true, true);
            m_CurItemDescriptions.drawHeaderCallback   = (Rect rect) => { EditorGUI.LabelField(rect, ""); };
            m_CurItemDescriptions.drawElementCallback += DrawItemDescription;
            m_CurItemDescriptions.elementHeight        = DESCRIPTION_HEIGHT;

            m_CurItemProperties = new ReorderableList(m_ItemDatabase, m_ItemList.serializedProperty.GetArrayElementAtIndex(m_ItemList.index).FindPropertyRelative("m_PropertyValues"), true, true, true, true);
            m_CurItemProperties.drawHeaderCallback   = (Rect rect) => { EditorGUI.LabelField(rect, ""); };
            m_CurItemProperties.drawElementCallback += DrawItemPropertyValue;
            m_CurItemProperties.elementHeight        = PROPERTY_HEIGHT;

            //Debug.Log(m_ItemList.index + " <-index | count-> " + m_ItemList.count);
            m_CurItemRequiredItems = new ReorderableList(m_ItemDatabase, m_ItemList.serializedProperty.GetArrayElementAtIndex(m_ItemList.index).FindPropertyRelative("m_Recipe").FindPropertyRelative("m_RequiredItems"), true, true, true, true);
            m_CurItemRequiredItems.drawHeaderCallback   = (Rect rect) => { EditorGUI.LabelField(rect, "Required Items"); };
            m_CurItemRequiredItems.drawElementCallback += DrawRequiredItem;
        }
Ejemplo n.º 2
0
        private void DrawItem(Rect rect, int index, bool isActive, bool isFocused)
        {
            if (m_ItemList.serializedProperty.arraySize > index)
            {
                SerializedProperty item        = m_ItemList.serializedProperty.GetArrayElementAtIndex(index);
                SerializedProperty displayProp = item.FindPropertyRelative("m_DisplayName");

                string toUse = (displayProp.stringValue == string.Empty) ? "m_Name" : "m_DisplayName";

                ItemManagementUtility.DrawListElementByName(m_ItemList, index, rect, toUse, isFocused, this);
            }
        }
Ejemplo n.º 3
0
        private void DrawListElement(ReorderableList list, Rect rect, int index, bool isActive, bool isFocused)
        {
            if (list.serializedProperty.arraySize == index)
            {
                return;
            }

            var element = list.serializedProperty.GetArrayElementAtIndex(index);

            rect.y += 2;
            EditorGUI.PropertyField(new Rect(rect.x, rect.y, 256f, EditorGUIUtility.singleLineHeight), element, GUIContent.none);

            ItemManagementUtility.DoListElementBehaviours(list, index, isFocused, this);
        }
Ejemplo n.º 4
0
        private void DrawItemPropertyValue(Rect rect, int index, bool isActive, bool isFocused)
        {
            var list = m_CurItemProperties;

            if (list.serializedProperty.arraySize == index)
            {
                return;
            }

            var element = list.serializedProperty.GetArrayElementAtIndex(index);

            rect.y      += 2f;
            rect.height -= 2f;
            ItemManagementUtility.DrawItemProperty(rect, element, m_PropertyList);

            ItemManagementUtility.DoListElementBehaviours(list, index, isFocused, this);
        }
Ejemplo n.º 5
0
        private void DrawItemDescription(Rect rect, int index, bool isActive, bool isFocused)
        {
            var list = m_CurItemDescriptions;

            if (list.serializedProperty.arraySize == index)
            {
                return;
            }

            var element = list.serializedProperty.GetArrayElementAtIndex(index);

            rect.y             += 2f;
            rect.height        -= 2f;
            element.stringValue = EditorGUI.TextArea(rect, element.stringValue);

            ItemManagementUtility.DoListElementBehaviours(list, index, isFocused, this);
        }
Ejemplo n.º 6
0
        private void DrawRequiredItem(Rect rect, int index, bool isActive, bool isFocused)
        {
            var list = m_CurItemRequiredItems;

            if (list.serializedProperty.arraySize == index)
            {
                return;
            }

            var element = list.serializedProperty.GetArrayElementAtIndex(index);
            var name    = element.FindPropertyRelative("m_Name");
            var amount  = element.FindPropertyRelative("m_Amount");

            rect.y      += 2f;
            rect.height -= 2f;

            // Name field.
            rect.width  = 128f;
            rect.height = 16f;

            int selectedIndex = ItemManagementUtility.GetItemIndex(m_CategoryList.serializedProperty, name.stringValue);

            selectedIndex = EditorGUI.Popup(rect, selectedIndex, m_ItemNamesFull);

            name.stringValue = m_ItemNames[Mathf.Clamp(selectedIndex, 0, 9999999)];

            // Amount.
            rect.x     = rect.xMax + 4f;
            rect.width = 16f;
            GUI.Label(rect, "x");

            rect.x          = rect.xMax;
            rect.width      = 64f;
            amount.intValue = EditorGUI.IntField(rect, amount.intValue);
            amount.intValue = Mathf.Clamp(amount.intValue, 1, 9999999);

            ItemManagementUtility.DoListElementBehaviours(list, index, isFocused, this);
        }
Ejemplo n.º 7
0
 private void DrawCategory(Rect rect, int index, bool isActive, bool isFocused)
 {
     ItemManagementUtility.DrawListElementByName(m_CategoryList, index, rect, "m_Name", isFocused, this);
 }