Cargue y muestre el modelo obj en la escena con FastObjImporter

En mi proyecto de Unity, me gustaría usar la clase FastObjImporter que se encuentra en Internet para poner obj en la escena. ¿Tengo que crear un GameObject vacío y asignarle un obj procesado?

Prueba con un objeto de juego vacío:

GameObject go = new GameObject("obj");
myMesh = FastObjImporter.Instance.ImportFile(objPath);
Instantiate(myMesh, Vector3.zero, Quaternion.identity);
go.AddComponent<MeshRenderer>();
go.GetComponent<MeshFilter>().mesh = myMesh;

Anteriormente lo intenté de esta manera pero tampoco funcionó:

GameObject go;
myMesh = FastObjImporter.Instance.ImportFile(objPath);
Instantiate(myMesh, Vector3.zero, Quaternion.identity);
go.GetComponent<MeshFilter>().mesh = myMesh;

¿Alguien podría explicar lo que estoy haciendo mal?

CÓDIGO:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using System.IO;

/// <summary>
/// Sample
/// </summary>
public class DriveTest : MonoBehaviour
{
    //public static readonly string REQUIRED_MIME = "image/jpeg";
    //public string filePath;
    public string objPath;
    bool initInProgress = false;
    GoogleDrive drive;
    public string url;
    List<GoogleDrive.File> remoteObjFiles;

    public Mesh myMesh;
    public GameObject go;

    /* ---------------------------------------------------------------------------------------------------------------------------------- */
    void Start()
    {
        objPath = Application.persistentDataPath + "/testObj.obj";
        StartCoroutine(ImportObj());
        go = new GameObject("obj");
    }

    /* ---------------------------------------------------------------------------------------------------------------------------------- */

    void Update()
    {

        if (Input.GetKey(KeyCode.Escape))
            Application.Quit();
    }

    /* ---------------------------------------------------------------------------------------------------------------------------------- */

    IEnumerator ImportObj()
    {
        initInProgress = true;

        drive = new GoogleDrive();
        var driveInit = drive.Initialize();
        while (driveInit.MoveNext())
            yield return null;

        initInProgress = false;

        for (;;)
        {
            ( SEARCHING AND SETTING DOWNLOAD FOLDER IN GDRIVE )

            var download = drive.DownloadFile(remoteObjFiles[0]);
            yield return StartCoroutine(download);
            var data = GoogleDrive.GetResult<byte[]>(download);

            if (File.Exists(objPath))
            {
                File.Delete(objPath);
                File.WriteAllBytes(objPath, data);
            }
            else
                File.WriteAllBytes(objPath, data);

            Debug.Log("Obj: " + remoteObjFiles[0].ToString());

            if (File.Exists(objPath))
            {
                Debug.Log("Loading OBJ from the device");
                myMesh = FastObjImporter.Instance.ImportFile(objPath);
                Debug.Log("Obj imported...");
                Instantiate(myMesh, Vector3.zero, Quaternion.identity);
                go.AddComponent<MeshRenderer>();
                go.GetComponent<MeshFilter>().mesh = myMesh;
            }
            break;
        }
}

Saludos

Respuestas a la pregunta(1)

Su respuesta a la pregunta