Editor Tool to Change Unity References?

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?

How about going one level up… How about having GameObject specific per platform? A script on each version of the GO would turn itself off if on the wrong platform.

As for going it by Reflection, it’s really not as slow as you might think. You could parse thousand of objects every second with ease.

A script to remove GameObjects on a specific platform would handle a lot of cases, but not every case. If there were other Objects that had a reference to the GameObject you wanted to replace, these references would still have to be changed to point to the replacement GameObject.

It might be possible to get away with just the ability to delete GameObjects per platform, but to solve the reference problem, you would have to make duplicates of any GameObject with references to GameObjects that had to be replaced. And this would propagate if anything had a reference to those GameObjects. Then you would be left with a bunch of duplicates and a maintenance nightmare if you ever had to change anything, since you have to change all the duplicates whenever you have to make a change to any one of them.