Search code examples
unity-game-enginetexture-mapping

Apply a custom image to a cuboid in Unity


I'm stumped having watched countless YouTube videos and read almost as many articles.

I have created an image (in Pixelmator) which I want to apply to a cuboid in Unity. The cuboid dimensions in Unity are 0.86 x 0.54 x 0.02. I have created a number of images to wrap around the cuboid. The first was in a cross shape, the total dimensions being 665x219 where the image comprised the left-hand side, the front, the right-hand side and the back across the middle with the top and bottom.

I created a material in Unity and then added the image to the Albedo of the image, but when I set the texture type to default, the texture shape to cube and the mapping to either auto or 6-sided, the image will no longer attach to the material.

I then tried creating a new image comprising 512x512 squares, firstly in the cross layout and secondly in a long line (with the front and back images as the last two squares) and applied the settings as above, but still couldn't get the image to apply to the cuboid.

If I leave the image as texture shape = 2D, the image can be applied to the material and the cuboid, but is stretched rather than wrapped around the cuboid.

I suspect I'm not using the correct language or approach, but am now stumped as to what I should be looking for to solve my problem. UVMaps?


Solution

  • Turns out UVMaps are the right answer. I adjusted my image to be 1024x1024, installed the ProBuilder component, launched the UV Editor and fit the image to the faces of my cuboid. Sounds easier than it actually was, but I'm set now.