Issue with materials on runtime-loaded mesh.
Hello,
I have a very weird issue : I am using the wiki's .obj runtime importer (http://wiki.unity3d.com/index.php?title=ObjImporter)
My .obj files have no uv. However, I should be able to -at least- set uniform colors to models once they are imported. What happens is that all the .obj I import with this script are completly black when I add a diffuse shader with a color to them.
I have no clue of what is happening. The issue seems to come from the generated mesh itself (maybe the UV?).
Do someone knows what is happening here ? Thanks in advance.
Here is the code that calls the ObjImporter : GameObject newobject = new GameObject();
if (!string.IsNullOrEmpty(path))
{
Mesh holderMesh = new Mesh();
ObjImporter newMesh = new ObjImporter();
holderMesh = newMesh.ImportFile(path);
newobject.AddComponent<MeshRenderer>();
MeshFilter filter = newobject.AddComponent<MeshFilter>();
filter.mesh = holderMesh;
newobject.GetComponent<Renderer>().material = Resources.Load("Materials/Default", typeof(Material)) as Material;
}
Your answer
Follow this Question
Related Questions
Automatically assign hundred of textures to .obj file 0 Answers
Help with mesh Texture Seems,Texture Showing Seems 0 Answers
Importing multiple textures to a multi-part mesh 0 Answers
Why does my model not display proper material? 2 Answers
Use a Raycast to get the Material from a shared Mesh (ProBuilder Object) 0 Answers