Import FBX at Runtime in UNITY.

Started by
1 comment, last by swiftcoder 9 years, 6 months ago

Hello Everyone,

I have been trying to research on loading FBX dynamically in unity. On various forums, I have found that one can just not load resources dynamically from a path on a drive at runtime. The solution to this till now is to read the FBX and create mesh and then do the material mapping etc.

I have to load upto 7GB of data into unity. If I call the data into editor, it crashes. What is the best way to do so?

Hope to receive a reply soon.

Thanks in advance.

Videep

Advertisement

If the data is in your resources folder for unity you should be able to load it programatically as a normal resource load, even if it's not added to your scene.

Here's some code I use for loading fbx entities at runtime for weapons and the like. Having said that. loading 7GB of data at runtime isn't going to be much fun....


 public void LoadAndAttachModel(String boneName, String modelName)
    {
        Transform boneTransform = GladiusGlobals.FindChild(boneName, gameObject.transform);
        if (boneTransform != null)
        {
            GameObject load = Instantiate(Resources.Load(GladiusGlobals.ModelsRoot + modelName)) as GameObject;
            if (load != null)
            {
                load.transform.parent = boneTransform;
                load.transform.localPosition = Vector3.zero;
                load.transform.localRotation = Quaternion.Euler(new Vector3(90, 90, 0));
                load.transform.localScale = new Vector3(100f, 100f, 100f);
            }
        }
        else
        {
            Debug.LogWarning("Can't find boneName : " + boneName);
        }
    }


I have been trying to research on loading FBX dynamically in unity.

FBX is generally not a good runtime format, and one of the major reasons is the size of assets encoded in FBX.

Unity has a built-in mechanism for this, in the form of Asset Bundles. Unfortunately, these are only available to users with a Pro license.

If you don't have a Pro license, you might want to look at the community-provided MeshSerializer script.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

This topic is closed to new replies.

Advertisement