- Home /
way to get all components of type in all scenes and prefabs
Our use-case: we have a component with an editor-script that exposes a dropdown list, letting you choose values from a json based on some key, e.g.:
"colors": {
"Background": { "r": 100, "g": 100, "b": 100, "a": 255 },
"Foreground": { "r": 255, "g": 255, "b": 255, "a": 255 }
}
The Inspector drop-down list is dynamically populated with these values, and serializes the choice by key (e.g. "Foreground").
Now we want to create an EditorWindow that lets you rename keys. This is a controlled process, of course, which renames the key inside the json and at the same time should find all references to that key (in scene objects in all scenes as well as in all prefabs in the asset hierarchy), and update them to the new value.
I haven't found anything in the API docs and neither did I find any third-party solutions. Does anyone know of an existing solution to this? It only needs to work in UnityEditor of course, so Editor dependencies are ok.
Thanks!
have you tried using tags? so you can loop through all of them http://answers.unity3d.com/questions/50208/loop-through-all-objects-with-same-tag.html
Answer by tanoshimi · Mar 03, 2017 at 12:23 PM
From your description, it sounds like you're looking for FindObjectsOfTypeAll?
Your answer
Follow this Question
Related Questions
How to load 3d models into script as one object 0 Answers
How do I get an array of names of all the sprites in a project, with an editor script? 2 Answers
How do you edit default components? 1 Answer
EditorUtiltiy.GetAssetPreview(Object asset) 0 Answers
can I update prefab Assets with new 3D files without resetting their components? 2 Answers