Ejemplo n.º 1
0
    private GameObject TriLibLoad(byte[] fileData)
    {
        // Load the .obj using TriLib
        GameObject targetObject;

        using (TriLib.AssetLoader assetLoader = new TriLib.AssetLoader())
        {
            targetObject = assetLoader.LoadFromMemory(fileData, ".obj");
        }
        return(targetObject);
    }
Ejemplo n.º 2
0
    private void loadItem(FileData item)
    {
        RuntimePreviewGenerator.OrthographicMode = true;
        RuntimePreviewGenerator.PreviewDirection = new Vector3(-1, -1, -1);

        using (var assetLoader = new TriLib.AssetLoader())
        {
            try
            {
                var assetLoaderOptions = TriLib.AssetLoaderOptions.CreateInstance();
                var wrapperGameObject  = gameObject;
                //assetLoaderOptions.AutoPlayAnimations = true;

                //Use this for PC
                //GameObject loaded = assetLoader.LoadFromFile("C:/Users/xuhzc/Downloads/objects/stand.OBJ", assetLoaderOptions);  //This can be a .fbx file or a .obj file

                //Use this for Android
                GameObject loaded = assetLoader.LoadFromFile(item.filePath, assetLoaderOptions, wrapperGameObject);  //This can be a .fbx file or a .obj file

                loadedGameObject = Instantiate(loaded);
                loadedGameObject.transform.position   = new Vector3(10000f, 10000f, 10000f);
                loadedGameObject.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);

                BoxCollider c = loadedGameObject.AddComponent <BoxCollider>();
                Debug.Log("================box=====================");
                c.size   = new Vector3(50, 50, 50);
                c.center = new Vector3(0, 25, 0);
                Destroy(loaded);
            }
            catch (Exception e)
            {
                Debug.LogError(e.ToString());
            }
        }

        addItem(loadedGameObject);
    }