script to assign different texture from a single material having all the textures
so i am trying to optimize my game by reducing the draw calls as it lags very badly on android devices ! all the objects in my game are cubes of same size ( 1 x 1 x 1 ). i have a single material for all the objects ! the material have all the textures that are needed in my game . how can i assign different textures to my blocks from that material ? please provide me a script or any better way to do this : )
I hope you mean the texture of the one material holds all textures at once like an atlas. If so, your cubes needs to index their particular past in that texture by UV coordinate. they go from 0 to 1 on x and y. so you either configure the UVs for each cube to match their respective patch in the atlas, our you recreate the UV array of the mesh in Unity and assign UVs there. As a tip: if all sides of a cube were to show the same patch in the lower left corner and the dimensions are 64*64 and the atlas is 1024*1024, coordinates would be 0,0 and 0.0625,0.0625
@hexagonius yes ! thats exactly what i was talking about ! i want to make an atlas ? but how will i assign those atlas textures to individual cubes ? for example i have two cubes , cube1 & cube2 and a texture atlas of 200 x 100 resolution having two diffferent textures of 100x100 ! now what scripts should i add to those cubes ? i want all the sides of a cube to have same texture ! please help me anytime when you are free