- Home /
Performance texture replace vs prefab instantiate
which operation is faster to perform or has the least cost during runtime.
having a single prefab mesh and replacing a texture during runtime like so :
gameObject.renderer.material.mainTexture = someTexture
or
having multiple prefabs with the same mesh but different textures and instantiating the one you want during runtime, like so.
GameObject go = Instantiate(Resources.Load("MyPrefab1")) as GameObject;
some background infomation: everytime the player enters a new area in my game, he is presented with a procedurally generated scene where he sees the a few character models with different textures applied. The textures are randomly chosen and the number of models is always less than the number of textures.
I need this game to run on mobile devices and i would like the scene to load reasonably fast. hence the question as to which is faster.
I understand that i will need to instantiate the objects in either case, however there are about 50 textures and i would prefer to avoid having to create prefabs for all of them if i have to.
Your answer