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.
asked Mar 30 '10 at 05:57 AM
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.
answered Mar 30 '10 at 07:45 AM
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
While the following assigns a texture through code that is stored in the resources folder (example from the Docs):
Hope that helps, sorry I don't have an answer for why your texture isn't showing up.
answered Mar 30 '10 at 06:56 AM