Hi,
I have been trying to import a dynamic object at run time with unity. This is my scenario : I am designing a ball throw game, and when the user successfully throws a ball at the target, I will make an API call that will return a 3D object and I need to show it to the user. So far, I have tried creating an empty gameobject, and attached a c# script that will import a .obj file from my disc and attach it.
This is the code:
Mesh holderMesh = new Mesh();
ObjImporter importer = new ObjImporter();
holderMesh = importer.ImportFile(@"<path>");
MeshRenderer renderer = gameObject.AddComponent<MeshRenderer>();
MeshFilter filter = gameObject.AddComponent<MeshFilter>();
filter.mesh = holderMesh;
But when running in unity, there is no trace of the object, and when I run in Visual studio, the background turns pink - and in both unity and VS, other static assets are present as usual.
Can you tell me if I am doing something wrong, and what is the best way to return a 3D object with texture info from server that can be easily loaded into unity at runtime?