- Home /
Attaching an Image to a 3D Cube
Hello!
I'd like to add a "billboard" to a wall in my game, but I don't know how to attach a picture to a cube. How can I do that? Materials?
Thanks in advance!
Answer by Cherno · Jul 12, 2015 at 03:56 PM
Either you apply a material using the billboard texture directly to the cube, or you apply it to a plane and place that on the cube's surface. Either way, you have to UV Map it. This is done either in your 3d modelling application or via script. Look up the Unity Scripting Manual for mesh.uv for the latter.
Answer by SimRuJ · Feb 09 at 02:55 PM
Using a plane works (you should now use a quad instead because they've got less vertices) but then you have to create a material and find a proper shader, which is a bit of a pain if you've got multiple cubes that all need an image. Instead you can simply use a sprite (tested with Unity 2021.1)!
Copy the image into the "Assets" folder
Set its "Texture Type" to "Sprite (2D and UI)" and adjust the settings accordingly
Create an empty GameObject child for the cube
Add a "Sprite Renderer" component
Now you can simply set the image as its sprite and move the sprite's GO forward a bit, so it's actually visible (e.g. -0.51)
That's it!
Your answer