0

I download a GameObject(FBX format) from the Url and save as a byte[]. After saving, I can not access the file on Android and I want to convert it to GameObject after downloading from the byte.

Also Resources.Load not working!
This is my code snippet:

IEnumerator DownloadFBX()
{
    using (var webRequest = UnityWebRequest.Get(Url))
    {
        yield return webRequest.SendWebRequest();
        if (webRequest.isNetworkError)
        {
            Debug.LogError(webRequest.error);
        }
        else
        {
            File.WriteAllBytes(Path.Combine(Application.persistentDataPath + "/Resources/", "Handgun.fbx"), webRequest.downloadHandler.data);
            // Now I want create GameObject from byte[]. Resources.Load not working !
        }
    }
}    
Mehdi
  • 1
  • 3

1 Answers1

0

I don't believe it is possible to do what you are trying to do. Unity can't directly load an FBX into a GameObject. Check out this link to the Unity forums where someone asked a similar question.

The best method would be to create a GameObject with your FBX in the Unity editor and then create an AssetBundle with it. Then you can load that AssetBundle at runtime.

JCH
  • 170
  • 11