Example #1
0
 public static List <GameObject> FindObjectsByName(string name, bool caseSensitive, bool includeInactive, bool matchWholeWord)
 {
     return(FindObjectsOfType <Transform>(includeInactive)
            .Where(obj => StringMatchHelper.DoesNameMatch(obj.name, name, caseSensitive, matchWholeWord))
            .Select(obj => obj.gameObject)
            .ToList());
 }
Example #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);
        }
Example #3
0
        public static List <Type> GetTypesByName(string name, bool caseSensitive, bool matchWholeWord)
        {
            name = name.Trim();
            List <Type> foundTypes = new List <Type>();

            if (RESERVED_TYPES.ContainsKey(name))
            {
                foundTypes.Add(RESERVED_TYPES[name]);
                if (matchWholeWord)
                {
                    return(foundTypes);
                }
            }

            List <Assembly> trimmedAssemblies = GetAssemblies().Where(assembly => !IGNORED_ASSEMBLIES.Contains(assembly.GetName().Name)).ToList();

            foundTypes.AddRange(GetTypesInAssemblies(trimmedAssemblies).Where(type => StringMatchHelper.DoesNameMatch(type.Name, name, caseSensitive, matchWholeWord)));
            return(foundTypes);
        }