I want to create a game with a Minecraft style world. Now I need uv mapping for some cubes in my game. But I could not find any good tutorial in the internet. I want to use the following texture with an uv map: enter image description here

Each side of the cube has a texture with 64x64 pixels. The dirt texture on the right side has to be the top of the cube. Can anyone tell me how to use uv mapping in my case?

  • \$\begingroup\$ You need a program called blender for uv mapping, not unity \$\endgroup\$
    – user100681
    Mar 9, 2018 at 15:52
  • \$\begingroup\$ I already tried blender for it. But then I have cubes which scales are different from the cubes in Unity. \$\endgroup\$ Mar 9, 2018 at 15:57
  • \$\begingroup\$ that is not the problem. You cannot (directly) specify Uv coordinates using Unity; That's why 3D modeling programs are being used. All you need to do is create the model in blender, unwrap it to the wanted texture, import it into unity and set the "scale factor" option to a reasonable number(from the import settings window). If you don't want to do that, you can just scale the cube in blender \$\endgroup\$
    – user100681
    Mar 9, 2018 at 16:42
  • 2
    \$\begingroup\$ I'm confused. You already showed in a previous question that you have a script that will construct a cube mesh with your desired UV mapping. What more do you hope to learn from this question that isn't covered by your existing solution? I'll also second Philipp's caution: you will not be able to draw a large Minecraft world by spawning individual cubes. You'll need to construct a skin mesh of just the visible surfaces. \$\endgroup\$
    – DMGregory
    Mar 9, 2018 at 17:20
  • 2
    \$\begingroup\$ Then ask about your actual problem: "using this script [include code], I see artifacts on my cube. How can I correct these artifacts?" \$\endgroup\$
    – DMGregory
    Mar 9, 2018 at 17:29

1 Answer 1


You can specify UV coordinates in Unity: https://docs.unity3d.com/ScriptReference/Mesh-uv.html

The UV coordinates go from 0 to 1, and the index in the uv array corresponds the the vertex with the matching index in the vertices array. This Unity Answers post may prove useful. It lists the vertices in Unity's cube primitive. The top face is first in the vertices, so you would map the uvs of the top face in the first four indices of the uv array like this:

uv[0] = (1, .333)
uv[1] = (.75, .333)
uv[2] = (1, .667)
uv[3] = (.75, .667)

I'll leave it to you to figure out the rest of the faces. Of course, assigning the uvs in a script would be more ideal only if you are generating content at runtime, so making your own mesh in a program like blender would be more ideal ... or you could make a script that runs in the Editor to create a new mesh for you based on the cube primitive. You can do this using the AssetDatabase interface.

  • \$\begingroup\$ Can you add a full script I can use? \$\endgroup\$ Mar 9, 2018 at 17:17
  • \$\begingroup\$ I'll add part of a script from a similar project soon. But I would recommend following the links I posted. That first one has some example code for assigning uvs. \$\endgroup\$
    – tyjkenn
    Mar 9, 2018 at 17:27
  • \$\begingroup\$ You can specify UV coordinates, yes, but that's not the ideal solution sometimes. In this case, you might wanna do it this way, calculating the texture coordinates in relation to a spritesheet (since it's minecraft), but most of the times it's much better to uv unwrap your 3D models into a 3D modeling program like blender or maya \$\endgroup\$
    – user100681
    Mar 9, 2018 at 17:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .