- Home /
How to import .obj at runtime using Javascript?
I want the user to be able to load any obj at runtime from their own system files in a stand alone player. I know there is an ObjImporter in C# but I don't know C# and am very new to js. This is all I have so far...please help! :)
var load: System.IO.File;
private var loadbutton;
function OnGUI()
{
loadbutton = GUI.Button(Rect(900,640,100,100), "Load OBJ");
}
I think you are going to need an external tool to do that at run time I'm afraid - you should be able to use objreader.
Basically I'm wondering if this is what I'm looking for, and how I can re-write it using js so I can understand it better. http://unifycommunity.com/wiki/index.php?title=ObjImporter
That would work - I'd be tempted to not try to rewrite it and just use it as it is. It could be translated to JS - there's nothing in there which is impossible to change - do you want some help with that?
That'd be great! I'd use it as is, but I have no idea HOW to use it, since it can't be attached to a gameObject.
Well you can use that code from Javascript - just place it in a Plugins folder then do:
var mi = new ObjImporter();
var mesh = mi.ImportFile(yourFilename);
And it will work - you can access C# from JS if you put the C# in Standard Assets or Plugins.
Your answer

Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer
Runtime javascript 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Help converting C# to Javascript? 0 Answers