Esempio n. 1
0
        public static List <GameObject> GetGameObjectsWithPropertyTypes(List <Type> propertyTypes, bool includeInactive)
        {
            List <GameObject> results       = new List <GameObject>();
            List <Component>  allComponents = FindObjectsOfType <Component>(includeInactive);

            foreach (Component component in allComponents)
            {
                if (results.Contains(component.gameObject))
                {
                    continue;
                }
                List <PropertyInfo> properties = ReflectionHelper.GetPropertiesForType(component.GetType());
                bool found = properties.FirstOrDefault(property => propertyTypes.Contains(property.PropertyType)) != null;
                if (found)
                {
                    results.Add(component.gameObject);
                }
            }
            return(results);
        }
Esempio n. 2
0
        public static List <GameObject> GetGameObjectsWithPropertyName(string propertyName, bool caseSensitive, bool includeInactive, bool matchWholeWord)
        {
            propertyName = propertyName.Trim();

            List <GameObject> results       = new List <GameObject>();
            List <Component>  allComponents = FindObjectsOfType <Component>(includeInactive);

            foreach (Component component in allComponents)
            {
                if (results.Contains(component.gameObject))
                {
                    continue;
                }
                List <PropertyInfo> properties = ReflectionHelper.GetPropertiesForType(component.GetType());
                bool found = properties.FirstOrDefault(property => StringMatchHelper.DoesNameMatch(property.Name, propertyName, caseSensitive, matchWholeWord)) != null;
                if (found)
                {
                    results.Add(component.gameObject);
                }
            }
            return(results);
        }