|
I'm trying to put a material onto a mesh that I've imported from a .obj, but instead of the texture showing up, it shows a solid color that approximates the average hue of the texture. I can instantiate a cube from the GameObject menu, then drag the material onto it in the Hierarchy view and it shows up as expected, but if I drag my mesh from the project view onto the hierarchy view, then drag the material onto it, I only get a solid color. In case this is a strange way of doing things, I should probably also point out that I want to change the textures during the course of the game, so I don't want to apply them in the 3d app.
(comments are locked)
|
|
You need to UV map your objects. Without UV mapping, the hardware has no way of knowing how to apply the texture, so you just get a solid color. The built-in cube is UV mapped. Of course! Kicking myself now, I should've thought of that. Thanks.
Mar 30 '10 at 10:41 AM
straydogstrut
Facepalm I knew it should be something simple. Thanks also straydogstrut for your example of using material objects.
Mar 30 '10 at 08:28 PM
Jaimse Jorms
(comments are locked)
|
|
Hi Jaimse, I don't use .obj much, but I threw one I had lying around into Unity and applied a texture no problem. The normal workflow is to create a material first, unless you already have one from your 3d app, then set its texture and apply the material to the mesh. Don't confuse materials and textures. Materials define how your object looks through properties such as color, texture and which shader you're using. However, Unity usually creates a material for you if you don't have one when you apply a texture straight to an object, so I don't see how you would have problems. Do you see a material in the Project View? As for changing textures at runtime, look up
See the Docs: http://unity3d.com/support/documentation/ScriptReference/Material-mainTexture.html While the following assigns a texture through code that is stored in the resources folder (example from the Docs):
http://unity3d.com/support/documentation/ScriptReference/Resources.Load.html Hope that helps, sorry I don't have an answer for why your texture isn't showing up.
(comments are locked)
|
