예제 #1
0
        private void CreateListData(RuntimeSerializedProperty property)
        {
            var root = property.GetRootPath();
            // Try to find the grand parent in RuntimeReorderableListData
            var data = listDataDict.Find(listData => listData.Parent.Equals(root));

            if (data == null)
            {
                data = new RuntimeReorderableListData(root);
                listDataDict.Add(data);
            }

            data.AddProperty(property);
            data.EditableCallback = () =>
            {
                if (Application.isPlaying && property.HasAttribute <RuntimeObjectAttribute>())
                {
                    return(false);
                }
                return(true);
            };

            if (property.HasAttribute <ReorderableAttribute>())
            {
                var reorderableAttr = property.GetAttributes <ReorderableAttribute>()[0] as ReorderableAttribute;
                if (reorderableAttr != null)
                {
                    HandleReorderableOptions(reorderableAttr, property, data);
                }
            }

            if (property.HasAttribute <BackgroundColorAttribute>())
            {
                var bgColorAttr = property.GetAttributes <BackgroundColorAttribute>()[0] as BackgroundColorAttribute;
                if (bgColorAttr != null)
                {
                    HandleBackgroundColorOptions(bgColorAttr, property, data);
                }
            }

            if (property.HasAttribute <DropdownMenuAttribute>())
            {
                var dropDownAttr    = property.GetAttributes <DropdownMenuAttribute>()[0] as DropdownMenuAttribute;
                var reorderableList = data.GetPropertyList(property);

                reorderableTypeDict.Add(reorderableList, dropDownAttr.Type);
                reorderableList.onAddDropdownCallback += OnAddDropdownHandler;
                reorderableList.onRemoveCallback      += OnRemoveHandler;
            }

            if (property.HasAttribute <PropertyAttribute>())
            {
                foreach (var attr in property.GetAttributes <PropertyAttribute>())
                {
                    if (attr is ReorderableAttribute || attr is BackgroundColorAttribute || attr is DropdownMenuAttribute)
                    {
                    }
                    else
                    {
                        data.ElementAttributes.Add(attr as PropertyAttribute);
                    }
                }
            }
        }