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!

From your description, it sounds like you’re looking for FindObjectsOfTypeAll?