void SearchChanged()
 {
     using (var pooled = PooledList <ComponentElementBase> .Make())
     {
         var list = pooled.List;
         m_ComponentsRoot.Query <ComponentElementBase>().ToList(list);
         if (m_Filters.Count == 0)
         {
             list.ForEach(ce => ce.Show());
         }
         else
         {
             list.ForEach(ce =>
             {
                 var showShow = false;
                 foreach (var token in m_Filters)
                 {
                     if (ce.Path.IndexOf(token, StringComparison.InvariantCultureIgnoreCase) >= 0)
                     {
                         showShow = true;
                         break;
                     }
                 }
                 if (showShow)
                 {
                     ce.Show();
                 }
                 else
                 {
                     ce.Hide();
                 }
             });
         }
     }
 }
        void UpdateComponentOrder(EntityInspectorComponentOrder current)
        {
            m_CurrentComponentOrder.Reset();
            using (var pooledElements = PooledList <ComponentElementBase> .Make())
            {
                ComputeCurrentComponentOrder(m_CurrentComponentOrder, pooledElements);

                if (current == m_CurrentComponentOrder)
                {
                    return;
                }

                // Component removed since the last update
                using (var pooled = ComputeRemovedComponents(current.Components, m_CurrentComponentOrder.Components))
                {
                    var list = pooled.List;
                    foreach (var path in list)
                    {
                        var element = pooledElements.List.Find(ce => ce.Path == path);
                        element?.RemoveFromHierarchy();
                    }
                }

                // Tags removed since the last update
                using (var pooled = ComputeRemovedComponents(current.Tags, m_CurrentComponentOrder.Tags))
                {
                    var list = pooled.List;
                    foreach (var path in list)
                    {
                        var element = pooledElements.List.Find(ce => ce.Path == path);
                        element?.RemoveFromHierarchy();
                    }
                }

                // Component added since the last update
                using (var pooled = ComputeAddedComponents(current.Components, m_CurrentComponentOrder.Components))
                {
                    var list      = pooled.List;
                    var container = Target.Container;
                    foreach (var path in list)
                    {
                        PropertyContainer.Visit(ref container, m_InspectorVisitor, new PropertyPath(path));
                    }
                }

                // Tags removed since the last update
                using (var pooled = ComputeAddedComponents(current.Tags, m_CurrentComponentOrder.Tags))
                {
                    var list      = pooled.List;
                    var container = Target.Container;
                    foreach (var path in list)
                    {
                        PropertyContainer.Visit(ref container, m_InspectorVisitor, new PropertyPath(path));
                    }
                }
            }
        }
        public EntityQueryDesc BuildQuery(string input, out string unmatchedInput)
        {
            unmatchedInput = input;

            if (string.IsNullOrEmpty(input))
            {
                return(null);
            }

            var matches = k_Regex.Matches(input);

            if (matches.Count == 0)
            {
                return(null);
            }

            using (var componentTypes = PooledList <ComponentType> .Make())
            {
                var b   = new StringBuilder();
                var pos = 0;
                for (var i = 0; i < matches.Count; i++)
                {
                    var match      = matches[i];
                    var matchGroup = match.Groups["componentType"];

                    var length = match.Index - pos;
                    if (length > 0)
                    {
                        b.Append(input.Substring(pos, length));
                    }

                    pos = match.Index + match.Length;

                    if (m_ComponentTypes.TryGetValue(matchGroup.Value, out var includedType))
                    {
                        componentTypes.List.Add(includedType);
                    }
                }

                if (input.Length - pos > 0)
                {
                    b.Append(input.Substring(pos));
                }

                unmatchedInput = b.ToString();

                if (componentTypes.List.Count == 0)
                {
                    return(null);
                }

                return(new EntityQueryDesc {
                    Any = componentTypes.List.ToArray()
                });
            }
        }
        public static void ForceUpdateBindings(this VisualElement element)
        {
            using (var pooled = PooledList <IBinding> .Make())
            {
                var list = pooled.List;
                PopulateBindings(element, list);

                foreach (var binding in list)
                {
                    binding.PreUpdate();
                }

                foreach (var binding in list)
                {
                    binding.Update();
                }
            }
        }
Exemple #5
0
 public static PooledList <T> GetList <T>()
 {
     return(PooledList <T> .Make());
 }