- Home /
Hierarchy search "NOT" modifier?
I'd like to search for all gameobjects in the scene Hierarchy that do not contain a specific string. Is this possible?
For example something like "NOT door" would filter the Hierarchy to display every item that does not have "door" in their names. AFAIK "NOT" doesn't work as an argument, neither does "-" (the dash character).
Thanks!!
I have meshes for lightmapping only, not in-game rendering, which are named with the same prefix as their renderable counterparts (walls, floors, etc.) plus the postfix "_SelfIllum". For example: mesh "Wall01A_SelfIllum" casts light onto mesh "Wall01A".
I would like to exclude all these "_SelfIllum" meshes from the list, so I could easily select all the renderable meshes.
Take a list consisting of: Wall01A, Wall01A, Wall01A, Wall01A_SelfIllum, Wall01A_SelfIllum, Wall01A_SelfIllum, Wall01B, Wall01B. How do I quickly select the three Wall01A meshes and the two Wall01B meshes, without selecting the three _SelfIllum meshes?
If I have a giant list with hundreds of each of these names, then manually selecting the desired ranges becomes a labor-intensive task. Limiting the display with booleans (or better yet, regular expressions!) would make this a simple task.
Is there a better way?
O$$anonymous$$, thanks for the reply. It's needed at design-time only. Hopefully a feature for the future. Will see if I can script something short-term.
Totally agree! I am looking for such a feature right now as I have na$$anonymous$$g conventions which makes it easy to sort stuff but when I have lots of na$$anonymous$$g conventions it would be nice to filter out some stuff. Example:
SearchBar[ b_ t: $$anonymous$$eshFilter]
This gives me the results I want but it includes all the meshFilter objects that begin with "b_". Now I would like to exclude the ones that have "_Edges".
Perhaps Unity can add a feature like this:
SearchBar[ b_ !(_Edges) t: $$anonymous$$eshFilter]
Would be great to have more control in large projects.
I agree Eric!
Any self-respecting software with a search function ought to accept expressions. Doubly so when the target audience is programmers (or at least up there on the nerd spectrum).
Answer by toddisarockstar · Nov 09, 2018 at 01:33 AM
this is not recommended because it is not proficient. there are many ways to organize your object so you dont have to do this. but this is your answer: this find all objects without "door" in the name.
GameObject[] Everything = UnityEngine.Object.FindObjectsOfType<GameObject>() ;
int n = Everything.Length;
while (n>0) {n--;
if(Everything[n].activeInHierarchy){
if(!Everything[n].name.Contains("NOT")){
print ("I found: "+Everything[n].name);
}
}
}
Your answer
Follow this Question
Related Questions
string searching question 1 Answer
Search function in Hierarchy 1 Answer
what the hell is a int? (or a float, or boolean, or string!) 3 Answers
string deleting 1 Answer
Locate asset in hierarchy 1 Answer