Change a cube face with another texture


My question is hard for me to explain so please, do not hesitate to ask me for more details.

I work with a cube. This cube has a texture applied thanks to UV mapping in order to have a different color for each face of the cube. While the game is running I’d like to change one of the face of this cube to another texture (for example replacing the blue face by the “skull” texture). Then, this new face has to behave like it’s actually a face of the cube (ie: when I rotate the cube, the face rotate as it’s the actual blue face).

I looked for a solution and the simplest seems to be:

  • Instantiate a quad
  • Change the quad material to “skull texture”
  • Change rotation / position (minus very small number in order to avoid z-fight) to make it appear in front of the right face of the cube
  • Change the transform.parent to the cube transform property

Because the original cube on what I try to change a face may have already rotate (several time), I can’t manage to correctly align the quad on the right face.

I hope my question is clear enough.
If you have some other way to proceed and achieve the same thing, do not hesitate to share it.

Thank you.

Create a cube in max with 6 materials and submeshes and then easily assign different textures at runtime to different materials or just use a texture for the material with 6 defined parts for each side and change the data for that part at runtime using SetPixels method of Texture2d class. The first method is faster in some ways and slower in some other, If it’s not a common thing to change texture use the SetPixels method because rendering one material is faster than 6 ones.

PS — in an actual game you knwo how I would do this? Just swap it to ANOTHER DIFFERENT CUBE! it’s that simple. Heh!

YES. what you’re doing is just called a


it’s a great idea! Go for it.

i suggest you search on “decal” and read all about the various techniques thereof.

Note that you could also use a “projector”, if you like, for a different effect.

one trick i sometimes use, never for changing objects though is to use lights with a cookie. i mainly use it for graffiti as you get a nice effect after its baked blends in like graffitie would.

depending on what your doing you could do that, or have seperate cube textures with transparent sides over the cube, probably best bet is just to have flat images parented to the cube that are either enabled or disabled at run time, a bit like gui