예제 #1
0
        public void DrawProperies(PropertyData data)
        {
            var buttons = Utilities.FindByAttribute <ButtonAttribute, MethodInfo>(data.Value);

            DrawMethodButtons(data, buttons, ButtonAttribute.AlignTypes.Top);

            Dictionary <OrderItem, string> itemList = new Dictionary <OrderItem, string>();
            OrderItem items = new OrderItem("", 0);
            Dictionary <string, OrderItem> attrList = new Dictionary <string, OrderItem>();

            var iterator = data.Property.Copy();
            int index    = 0;

            for (bool enterChildren = true; iterator.NextVisible(enterChildren); enterChildren = false)
            {
                if (string.IsNullOrEmpty(data.Property.propertyPath) || iterator.propertyPath.IndexOf(data.Property.propertyPath, StringComparison.Ordinal) == 0)
                {
                    PropertyData itemData = new PropertyData(iterator.Copy(), data);
                    if ("m_Script" == iterator.propertyPath)
                    {
                        EditorGUI.BeginDisabledGroup(true);
                        Editor.Property.Draw(itemData);
                        EditorGUI.EndDisabledGroup();
                    }
                    else
                    {
                        string path = "";
                        foreach (var attribute in itemData.Attributes.Select(e => e as GroupAttribute))
                        {
                            if (attribute != null)
                            {
                                if (!attrList.ContainsKey(attribute.Name))
                                {
                                    attrList.Add(attribute.Name, new OrderItem(attribute, index));
                                }
                                path = path.Length < attribute.Name.Length ? attribute.Name : path;
                            }
                        }

                        itemList.Add(new OrderItem(itemData, index), path);
                        //var groupAttr = itemData.Attributes.FirstOrDefault(e => e is GroupAttribute) as GroupAttribute;
                        //items.Add(groupAttr != null ? groupAttr.Name, , new OrderItem(itemData, index));
                        //AddItem(items, new OrderItem(itemData, index));
                        index++;
                    }
                }
            }

            foreach (var pair in attrList)
            {
                items.Add(pair.Value, pair.Key);
            }

            foreach (var pair in itemList)
            {
                items.Add(pair.Key, pair.Value);
            }

            items.Sort();
            items.Draw(e => Editor.Property.Draw(e.Data));

            DrawMethodButtons(data, buttons, ButtonAttribute.AlignTypes.Bottom);
        }