I am trying to add a script to all game objects in a scene. I have gameobjects created in unity and gameobjects imported from 3d model software. The ones imported from a 3d model software makes the console get mad and say “You cant add script to this gameobject because its a generated prefab and can only be modified through an AssetPostProcessor” How can I make code to check if the gameobject is a generated prefab at runtime?
I’d try PrefabUtility.GetPrefabType.
It will return you a PrefabType and I think the following is what you are after:
- ModelPrefab
- ModelPrefabInstance
- DisconnectedModelPrefabInstance
Hope it helps, haven’t used that API before. It would be nice if you report back with findings to help document the usage of this API.