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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Load .FBX files during runtime with Unity - what are my options?

Discussion in 'Editor & General Support' started by JesperL, Dec 24, 2014.

  1. JesperL

    JesperL

    Joined:
    Oct 3, 2014
    Posts:
    15
    Hi everyone and happy holidays!

    I am a Unity beginner who is currently working on a small Unity project in which I will need to dynamically load .fbx files during runtime. I.e. I want to build a Windows Unity application in which the user can supply a .fbx file as a command line argument (or similar) which will then be shown in the scene.

    Is this possible at all? I did some searching and it seems I could use the Pro feature Asset Bundles for this, is this correct? Are there any other options available? If there are ways in which the fbx file must be converted or built in any way before passing it to the built Unity app that would works as well, as long as it is very easy for the end user to do so. Preferably, I do not want to require that the user has a Unity installation, just the built Unity app and a collection of fbx files.

    I'd really appreciate any help on this issue!
     
  2. Zerot

    Zerot

    Joined:
    Jul 13, 2011
    Posts:
    135
    No, you can't use assetbundles for that because that would require the user to have a unity pro install.

    You do not have a lot of options. If you have unity pro, then you could use the autodesk fbx sdk(you would need to write a c# managed wrapper for it most likely), but if you only have unity free(which is more likely because you are a beginner) you will either need to find a managed library for loading fbx, or write your own fbx loader which will not be easy.
     
    Ony likes this.
  3. JesperL

    JesperL

    Joined:
    Oct 3, 2014
    Posts:
    15
    Thanks for the reply! That's a bummer... I do not have the Pro version at the moment, but if it will be necessary for the project I might be able to get it. I have thought about getting it in the past and if it is needed now might be a good time.

    I did find a few plugins that might be of use, for example these two:

    https://www.assetstore.unity3d.com/en/#!/content/3147
    https://www.assetstore.unity3d.com/en/#!/content/12757

    Perhaps Unity Pro and one of those is the way to go if I cannot find any way to do it in the free version of Unity.
     
  4. Ony

    Ony

    Joined:
    Apr 26, 2009
    Posts:
    1,973
    If you absolutely need FBX then yeah, like Zerot says, but is there a way you can do it with OBJ? There are a few inexpensive dynamic OBJ loaders that might work for you.
     
  5. JesperL

    JesperL

    Joined:
    Oct 3, 2014
    Posts:
    15
    OBJ might actually work, but when importing the same object into Unity saved as both FBX and OBJ+MTL, FBX has worked a lot better for me, I'm having some issues with getting the MTL files to load. However there are probably a lot of things I could tweak to make OBJ work better. Ony, would you recommend any particular OBJ loaders?

    Also, what if I remove the constraint of having no Unity Editor installs on the end user's system? Would it be possible to, for example, create a script that loads my Unity project, imports a user specified FBX file, then builds and runs the project? The important thing would be that the process is automated since I cannot assume that the end users have any Unity experience.
     
  6. landon912

    landon912

    Joined:
    Nov 8, 2011
    Posts:
    1,579
    Obj files are quite easy to manually handle. Try looking into that over fbx.
     
  7. JesperL

    JesperL

    Joined:
    Oct 3, 2014
    Posts:
    15
    Thanks, I will do that. Still, I would like to explore some other options, for example creating some kind of script that loads a FBX file into unity, builds the project and then runs it. This application/game will not be publicly distributed so that would work OK as well, even though I would prefer not having to rely on a Unity installation on the end user's system.
     
  8. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,142
    There is an asset on the store that can handle runtime model importing, but it requires Unity Pro and is Windows-only.

    https://www.assetstore.unity3d.com/en/#!/content/12757
     
  9. JesperL

    JesperL

    Joined:
    Oct 3, 2014
    Posts:
    15
    I tried the trial version of that plugin at a friend's house, but it just crashed... There is another plugin on the Asset Store, but it's 250€ which is a bit steep if I am not certain it will work or not.

    On the other hand, I found this application built in Unity which has solved dynamic FBX import in a good way: http://www.realis3d.com/about-realis3d/viewer It has no problem importing the files I tried. Wish their solution was open source or available on the asset store.

    If anyone has any other suggestions, please let me know, I would be eternally grateful!