I am trying to develop a system that will allow us to easily manage content in our game for multiple versions on different platforms. We will be making changes to our scenes that are platform specific (objects w/ scripts needed for new features, different models, different materials, etc…).
As part of the build process, I would like to collect every Unity reference of a given type in my scene, look up the Object each reference points to in my table, make the references point to other objects based on the table, then save out the scene as a separate scene.
Ideally, there would be a function in Unity similar to FindObjectsOfType(), maybe called FindReferencesToObjectsOfType(). If this were C++, maybe it would return an array of Object** (pointer to an Object pointer) so we could change the thing the pointer points to. Since pointers to pointers aren’t a native feature of C#, maybe instead it would return an array of structs, each containing a System.Reflection.FieldInfo, Object pair?
I could probably do this manually by using FindObjectsOfType() to get every Object in the scene then iterate over each one looking at each of its fields using reflection (including arrays and serialized class types) and saving the FieldInfo, Object pairs myself. However, I imagine this would be incredibly slow to do this over each scene, each of which has a considerable number of Objects.
Is there anything in the Unity API that can help me with this?