Imagine you have a generic cube prefab with some scripts on it. Then you have 3 different 3D Models or “appearances”. Is it possible to choose one of those models at runtime and assign its shape and appearance to my generic cube?
Everything else except of the look(and shape) should be the same after the assignment.
Is something like this possible and fast enough? Or should I reconsider my approach here?
In order to get the shape, you can swap out the mesh:
GetComponent(MeshFilter).mesh = anotherMesh;
It is plenty fast enough, but it is not without its weaknesses. Depending your your use, you may have to swap out the material as well. And if you are using a collider, you likely have to swap out the sharedMesh of the collider. An alternate approach is to have an empty game object as a parent and have all three “looks” as child game objects. You then enable and disable the game object as needed.