Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Import OBJ Via Code (Natively)

Discussion in 'Scripting' started by AtomicPerception, Feb 21, 2016.

  1. AtomicPerception

    AtomicPerception

    Joined:
    May 29, 2013
    Posts:
    19
    Hi All,

    I am searching through the scripting help but I can't seem to find the function that will import an OBJ file, on-the-fly while the game is running. I assume this is possible, natively, without some external asset.

    Does anyone have a link to show some code on how to accomplish this task?

    Thanks
     
  2. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,026
    It isn't. The actual model importing is being handled by the editor. You'll need an asset to do it at runtime. Try this.

    http://wiki.unity3d.com/index.php?title=ObjImporter
     
  3. AtomicPerception

    AtomicPerception

    Joined:
    May 29, 2013
    Posts:
    19
    Thanks for the link to the code.

    Do you happen to know if that posted code can import OBJ files that contain quads or ngons?

    Is it assumed that when using Unity you have to pre-convert any OBJ files into a triangles only mesh in your host 3D application before export?
     
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,026
    A quick glance at the source seems to suggest its made for triangles only.

    I don't know. I haven't used OBJ in years. Best I can suggest is to experiment.