Ejemplo n.º 1
0
        //Loads an existing local file
        private void LoadFile(string fileExtension, string localFilename)
        {
            //Creates a new AssetLoader instance
            using (var assetLoader = new AssetLoader())
            {
                //Checks if the URL is a ZIP file
                if (fileExtension == ".zip")
                {
#if TRILIB_USE_ZIP
                    var localFilePath = FileUtils.GetFileDirectory(localFilename);

                    //Gets the first asset loadable by TriLib on the folder
                    var assetPath = GetReadableAssetPath(localFilePath);
                    if (assetPath == null)
                    {
                        Debug.LogError("No TriLib readable file could be found on the given directory");
                        return;
                    }

                    //Loads the found asset
                    _loadedGameObject = assetLoader.LoadFromFile(assetPath);
#else
                    throw new Exception("Please enable TriLib ZIP loading");
#endif
                }
                else
                {
                    //If the URL is not a ZIP file, loads the file inside the folder
                    _loadedGameObject = assetLoader.LoadFromFile(localFilename);
                }

                //Move camera away to fit the loaded object in view
                CameraExtensions.FitToBounds(Camera.main, _loadedGameObject.transform, 3f);
            }
        }
Ejemplo n.º 2
0
 //This function will run when the object is loaded
 private void OnFileDownloaded(GameObject loadedGameObject)
 {
     //Move camera away to fit the loaded object in view
     CameraExtensions.FitToBounds(Camera.main, loadedGameObject.transform, 3f);
 }