- Home /
2D cube material pattern not repeating
I'm trying to use a Cube in my 2D game as a background gameobject in which I want to set a repeating background image.
Here are the steps I followed:
Created a Cube, so I can see one of its faces. Great.
Created a new material and set it to Legacy > Diffuze.
Created a 50x50 seamless image in Photoshop.
Selected my 50x50 PNG images as the material's texture.
Set the Cube's material to this material I created.
Result: Rather than the image repeating as tiled, the cube shows the 50x50 image as streched along the Cube's side.
From reading various posts and solutions, I have already tried changing the material's Tiling numbers, but it just makes the image smaller, and not repeating.
What am I doing wrong here?
Thanks.
Answer by Bunny83 · Jun 23, 2019 at 10:38 AM
Are you sure you set the wrap mode of the texture to repeat when you imported the texture? Also keep in mind that a cube face is naturally mapped to the whole texture since that's how it has been unwrapped. That's how texture mapping works.
Finally if you work on a 2d game, why do you use a cube? If only one face is seen, use a Quad instead. Also it's highly recommended you create textures that have a resolution that is a power of two (32,64,128,256,512,1024, ...) otherwise your texture may be resampled to the nearest power of two unless you specify you want a non power of two texture. Though keep in mind that NPOT textures may not be supported on all devices and also are less efficient in memory usage and processing.