Spread material over multiple objects or cubes

Hello there,

I am making a game with cubes that react to physics and can be destroyed. I need to spread a material over these cubes so when the game starts they form an image. Like bricks in a wall with graffiti over the top.

I have made some progress in finding the SetTextureOffset and Scale but I can’t work out how to offset each texture by the right amount to make up my seamless image.

renderer.material.SetTextureScale(“_MainTex”, Vector2 (scaleX,scaleY));

renderer.material.SetTextureOffset(“_MainTex”, Vector2(transform.position.x/5, transform.position.y));

I have this which sets the material offset based on it’s position in the world. I will now go in and manually try to work out each offset value but there must be an easier way.

Thanks for your help

Will

Ups! forgot to post my idea as an answer:

“Isnt the size of a texture from 0 to 1? like 0% to 100% ? if so, I would just divide the number of “tiles” per row and column with width and height and use this tilesize for offset.”

Please use COMMENT on this answer @Wiplash, if you need further help.

Answers are meant to be answers to the question only. One answer can have many comments.