I save my gameobject on disk using http://wiki.unity3d.com/index.php?title=ExportOBJ.
all is good - Blender opens nicely.
I load from disk using http://wiki.unity3d.com/index.php?title=ObjImporter
Loaded object looks like broken or empty
I am struggling with it for a week now. I have googled and tried but nothing works. I think I am missing something simple here.
ObjImporter oi = new ObjImporter ();
objToSpawn = new GameObject("TAG_0");
//Add Components
objToSpawn.transform.parent = o.transform;
objToSpawn.AddComponent<MeshFilter>();
objToSpawn.AddComponent<MeshRenderer>();
var asd = oi.ImportFile (filepath);
objToSpawn.GetComponent<MeshFilter> ().mesh = asd;
objToSpawn.AddComponent<MeshCollider>().mesh = asd;
//http://docs.unity3d.com/ScriptReference/Mesh-uv.html
Vector3[] vertices = objToSpawn.GetComponent<MeshFilter>().mesh.vertices;
Vector2[] uvs = new Vector2[vertices.Length];
int i = 0;
while (i < uvs.Length) {
uvs <em>= new Vector2(vertices_.x, vertices*.z);*_</em>
* i++;*
* }*
* objToSpawn.GetComponent().mesh.uv = uvs;*
* objToSpawn.GetComponent ().mesh.RecalculateNormals();*
* objToSpawn.GetComponent ().mesh.RecalculateBounds ();*
* GameObject primitive = GameObject.CreatePrimitive(PrimitiveType.Plane);*
* primitive.active = false;*
* Material diffuse = primitive.GetComponent().sharedMaterial;*
* DestroyImmediate(primitive);*
* //fix diffuse*
* objToSpawn.renderer.sharedMaterial = diffuse;*
* objToSpawn.renderer.material.color = Color.red;*
thank in advance fro anykind of help