Beispiel #1
0
        private void BuildSearchableList()
        {
                        #if DEV_MODE || PROFILE_POWER_INSPECTOR
            Profiler.BeginSample("PopupMenu.BuildSearchableList");
                        #endif

            searchableListBuilt = true;

                        #if DEV_MODE || PROFILE_POWER_INSPECTOR
            Profiler.BeginSample("BuildSearchableList.GetFullLabelsInChildren");
                        #endif

            int count       = rootItems.Count;
            var pathBuilder = new List <string>(count);
            for (int n = count - 1; n >= 0; n--)
            {
                rootItems[n].GetFullLabelsInChildren(ref pathBuilder);
            }

                        #if DEV_MODE || PROFILE_POWER_INSPECTOR
            Profiler.EndSample();
                        #endif

            if (searchableList != null)
            {
                SearchableListPool.Dispose(ref searchableList);
            }
            searchableList = SearchableListPool.Create(pathBuilder.ToArray());

                        #if DEV_MODE && DEBUG_BUILD_SEARCHABLE_LIST
            Debug.Log("BuildSearchableList result:\n" + StringUtils.ToString(searchableList.Items, "\n"));
                        #endif


                        #if DEV_MODE || PROFILE_POWER_INSPECTOR
            Profiler.EndSample();
                        #endif
        }
 public static void Dispose(ref SearchableList disposing)
 {
     disposing.Filter       = "";
     cache[disposing.Items] = disposing;
     disposing = null;
 }
        private static void GenerateItems()
        {
            itemsGenerated = true;

            AddComponentUtility.BuildConflictingTypesDictionaryIfDoesNotExist();

            var assemblies    = AppDomain.CurrentDomain.GetAssemblies();
            int assemblyCount = assemblies.Length;

            rootGroups = new AddComponentMenuItem[0];

            Apply(InspectorUtility.Preferences.addComponentMenuConfig);

            var componentTypes = TypeExtensions.ComponentTypes;

            for (int n = componentTypes.Length - 1; n >= 0; n--)
            {
                var type = componentTypes[n];
                if (type.IsAbstract || type.IsGenericTypeDefinition || type.IsBaseComponentType())
                {
                    continue;
                }

                // All GameObjects will always already have a Transform or RectTransform component
                // and only one can be added to a GameObject, so don't show them in the menu.
                if (type == Types.Transform ||
                    type == Types.RectTransform)
                {
                    continue;
                }

                if (Contains(type))
                {
                    continue;
                }

                //hide obsolete items from the menu
                if (type.IsDefined(Types.ObsoleteAttribute, false))
                {
                                        #if DEV_MODE && DEBUG_SKIP_ADDING
                    Debug.LogWarning("Skipping adding " + type.Name + " to Add Component menu because it has the Obsolete attribute");
                                        #endif
                    continue;
                }

                Add(type);
            }

            itemsByLabel.Clear();
            for (int n = rootGroups.Length - 1; n >= 0; n--)
            {
                rootGroups[n].GetClassLabelsFlattened(ref pathBuilder, ref itemsByLabel);
            }

            if (searchableList != null)
            {
                SearchableListPool.Dispose(ref searchableList);
            }
            searchableList = SearchableListPool.Create(pathBuilder.ToArray());

            pathBuilder.Clear();

            // if add component menu config contains any invalid items, remove them
            RemoveInvalidItems(ref rootGroups);

            Sort(rootGroups);
        }
Beispiel #4
0
        private static void GenerateItems()
        {
            itemsGenerated = true;

            AddComponentUtility.BuildConflictingTypesDictionaryIfDoesNotExist();

            var assemblies    = AppDomain.CurrentDomain.GetAssemblies();
            int assemblyCount = assemblies.Length;

            rootGroups = new AddComponentMenuItem[0];

            Apply(InspectorUtility.Preferences.addComponentMenuConfig);

            var componentTypes = TypeExtensions.ComponentTypes;

            for (int n = componentTypes.Length - 1; n >= 0; n--)
            {
                var type = componentTypes[n];
                if (type.IsAbstract || type.IsGenericTypeDefinition)
                {
                    continue;
                }

                //Special case. For some reason Unity didn't make these abstract
                //but they still should not be shown in the Add Component menu
                if (type == Types.MonoBehaviour ||
                    type == Types.Effector2D ||
                    type == Types.Behaviour ||
                    type == Types.Collider ||
                    type == Types.Collider2D ||
                    type == Types.Renderer
                                #if !UNITY_2019_3_OR_NEWER
                    || type == Types.GUIElement
                                #endif
                    || type == Types.Joint ||
                    type == Types.Joint2D ||
                    type == Types.AnchoredJoint2D ||
                    type == Types.PhysicsUpdateBehaviour2D ||
                    type == Types.Tree ||
                    type == Types.ParticleSystemRenderer ||
                    type == Types.AudioBehaviour
                                #if UNITY_2017_2_OR_NEWER
                    || type == Types.GridLayout
                                #endif
                    )
                {
                    continue;
                }

                //all GameObjects will always already have a Transform or RectTransform component
                //and only one can be added to a GameObject, so won't show them in the menu
                if (type == Types.Transform ||
                    type == Types.RectTransform)
                {
                    continue;
                }

                if (Contains(type))
                {
                    continue;
                }

                //hide obsolete items from the menu
                if (type.IsDefined(Types.ObsoleteAttribute, false))
                {
                                        #if DEV_MODE && DEBUG_SKIP_ADDING
                    Debug.LogWarning("Skipping adding " + type.Name + " to Add Component menu because it has the Obsolete attribute");
                                        #endif
                    continue;
                }

                Add(type);
            }

            itemsByLabel.Clear();
            for (int n = rootGroups.Length - 1; n >= 0; n--)
            {
                rootGroups[n].GetClassLabelsFlattened(ref pathBuilder, ref itemsByLabel);
            }

            if (searchableList != null)
            {
                SearchableListPool.Dispose(ref searchableList);
            }
            searchableList = SearchableListPool.Create(pathBuilder.ToArray());

            pathBuilder.Clear();

                        #if DEV_MODE
            AssertHasNoEmptyGroups(rootGroups);
                        #endif

            // if add component menu config contains any invalid items, remove them
            RemoveInvalidItems(ref rootGroups);
        }