- Home /
Applying materials/textures on imported fbx, dae, etc
Thank you in advance for any help!
I've been learning how to use some 3d modeling tools like blender and sketchup so as to improve the complexity of objects in my game but have run into a problem that I can't seem to find a solution for here in the forum/answers or anywhere else.
Here's my problem:
I create a cube in Blender.
I export the cube as an fbx file (I've also tried all the other formats including dae)
I import the fbx file into my unity project/scene
I try to add a texture to one of the materials associated with the cube
Nothing happens
If I change the "Main Color" of the material, the cube's color does change. But I can't seem to figure out why I can't see the added texture... I run into the same problem even when I create a new material & texture and apply it to the cube. Color works, but no texture is visible?
Am I just doing something wrong, or is there something that I'm missing/not understanding.
Any help would be much appreciated, thank you!
Answer by FatWednesday · Feb 17, 2013 at 07:03 PM
Not being a modeler, i have almost no experience with the tools themselves, but does blenders cube primitive come with UV coordinates already set? and are those coordinates being exported with the fbx?
That would be my first question when dealing with a non-displaying texture. Here is a small C# script that you can attach to any object with a mesh filter. Drop this script on it and run, you should get the uv coordinates for the object. At least one of the channels (preferably the 1st channel unless you're using a shader that will look in the other channels) should have your uv coordinates. If there are no coordinates being output, then the cube was either never mapped, or material coordinates aren't being exported with the fbx.
public class UvConfirm : MonoBehaviour
{
void Awake ()
{
MeshFilter meshRend = GetComponent<MeshFilter>();
if (meshRend != null)
{
LogUVs(meshRend.sharedMesh.uv, 0);
LogUVs(meshRend.sharedMesh.uv1, 1);
LogUVs(meshRend.sharedMesh.uv2, 2);
}
}
private void LogUVs(Vector2[] uvs, int channel)
{
string output = "ArrayData: (";
for (int i = 0; i < uvs.Length; i++)
{
output += uvs[i].ToString();
if (i < uvs.Length - 1) output += ", ";
}
output += ")";
Debug.Log("UV Channel " + channel.ToString() + ": " + output);
}
}
Hey thanks for the response. I added the script to one of the objects. This was the output:
UV Channel 0: ArrayData: ((0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0))
I'm assu$$anonymous$$g that this means, as you said "the cube was never mapped" - being very new to all of this, I'm unfamiliar with the "mapping" process, but I do now have a way of looking into a possible solution. Thank you!
Answer by bigOrangeJuice · Feb 17, 2013 at 08:22 PM
FatWednesday, thank you again.
The solution, after utilizing your script to reveal the lack of UV information, was to return to Sketchup and simply added a texture to my model. I then, the same as before, exported it and imported it to Unity.
Now, I am able to successfully add textures directly in unity!
I have the same problem with an Alias imported object but I didn't get the solution. Any help please ?
Your answer
Follow this Question
Related Questions
Multiple UVs from Blender (Problem) 0 Answers
Unity not importing materials from blender. 0 Answers
materials and textures import from max. 1 Answer
What is the best way to export textures with objects? 2 Answers
textures importing dark 1 Answer