예제 #1
0
 public void AppendContent(CategoryDropdownContent content)
 {
     foreach (var item in content.Items)
     {
         Items.Add(new Item
         {
             value        = item.value,
             categoryName = item.categoryName,
             itemType     = item.itemType,
             displayName  = item.displayName
         });
     }
 }
예제 #2
0
        /// <summary>
        /// This will iterate over the current UI Builder hierarchy and extract the supported animatable properties.
        /// This will allow to display the options to users in the same order that they are in the builder.
        /// </summary>
        void GenerateTransitionPropertiesContent()
        {
            var content = new CategoryDropdownContent();

            content.AppendValue(new CategoryDropdownContent.ValueItem
            {
                value       = "all",
                displayName = "all"
            });

            foreach (var kvp in m_StyleCategories)
            {
                var groupName = kvp.Key.text;
                if (string.IsNullOrWhiteSpace(groupName) || groupName == "Transition Animations")
                {
                    continue;
                }

                content.AppendCategory(new CategoryDropdownContent.Category {
                    name = groupName
                });

                foreach (var element in kvp.Value)
                {
                    var styleName = element.GetProperty(BuilderConstants.InspectorStylePropertyNameVEPropertyName) as string;

                    if (!string.IsNullOrWhiteSpace(styleName))
                    {
                        var styleId = StyleDebug.GetStylePropertyIdFromName(styleName);
                        if (!StylePropertyUtil.IsAnimatable(styleId))
                        {
                            continue;
                        }

                        if (!string.IsNullOrWhiteSpace(styleId.ToString()))
                        {
                            content.AppendValue(
                                new CategoryDropdownContent.ValueItem
                            {
                                categoryName = groupName,
                                value        = styleName,
                                displayName  = ObjectNames.NicifyVariableName(styleId.ToString())
                            });
                        }
                    }

                    if (!(element is FoldoutField foldoutField))
                    {
                        continue;
                    }
                    var hashSet = HashSetPool <StylePropertyId> .Get();

                    try
                    {
                        foreach (var bindingPath in foldoutField.bindingPathArray)
                        {
                            var shortHandId = StyleDebug.GetStylePropertyIdFromName(bindingPath).GetShorthandProperty();
                            if (shortHandId == StylePropertyId.Unknown || !hashSet.Add(shortHandId))
                            {
                                continue;
                            }

                            if (!StylePropertyUtil.IsAnimatable(shortHandId))
                            {
                                continue;
                            }

                            if (!string.IsNullOrWhiteSpace(shortHandId.ToString()))
                            {
                                content.AppendValue(
                                    new CategoryDropdownContent.ValueItem
                                {
                                    categoryName = groupName,
                                    value        = BuilderNameUtilities.ConvertStyleCSharpNameToUssName(
                                        shortHandId.ToString()),
                                    displayName = ObjectNames.NicifyVariableName(shortHandId.ToString())
                                });
                            }
                        }
                    }
                    finally
                    {
                        HashSetPool <StylePropertyId> .Release(hashSet);
                    }
                }
            }

            content.AppendSeparator();
            content.AppendValue(new CategoryDropdownContent.ValueItem
            {
                value       = "none",
                displayName = "none"
            });

            content.AppendValue(new CategoryDropdownContent.ValueItem
            {
                value       = "initial",
                displayName = "initial"
            });

            content.AppendValue(new CategoryDropdownContent.ValueItem
            {
                value       = "ignored",
                displayName = "ignored"
            });

            TransitionPropertyDropdownContent.Content = content;
        }