SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.IO;
  2. using System.Collections;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5.  
  6.  
  7. public class ObbExtractor : MonoBehaviour
  8. {
  9.  
  10.     void Start()
  11.     {
  12.         StartCoroutine(ExtractObbDatasets());
  13.     }
  14.  
  15.     private IEnumerator ExtractObbDatasets()
  16.     {
  17.         //TUTAJ NAZWY PLIKOW KTORE SA W STREAMING ASSETS
  18.         string[] filesInOBB = { "<name>.dat", "<name>.xml" };
  19.         foreach (var filename in filesInOBB)
  20.         {
  21.             string uri = Application.streamingAssetsPath + "/Vuforia/" + filename;
  22.  
  23.             string outputFilePath = Application.persistentDataPath + "/Vuforia/" + filename;
  24.             if (!Directory.Exists(Path.GetDirectoryName(outputFilePath)))
  25.                 Directory.CreateDirectory(Path.GetDirectoryName(outputFilePath));
  26.  
  27.             var www = new WWW(uri);
  28.             yield return www;
  29.  
  30.             Save(www, outputFilePath);
  31.             yield return new WaitForEndOfFrame();
  32.         }
  33.  
  34.         // When done extracting the datasets, Start Vuforia AR scene
  35.         //SceneManager.LoadScene("0-Splash");
  36.     }
  37.  
  38.     private void Save(WWW w, string outputPath)
  39.     {
  40.         File.WriteAllBytes(outputPath, w.bytes);
  41.  
  42.         // Verify that the File has been actually stored
  43.         if (File.Exists(outputPath))
  44.         {
  45.             Debug.Log("File successfully saved at: " + outputPath);
  46.         }
  47.         else
  48.         {
  49.             Debug.Log("Failure!! - File does not exist at: " + outputPath);
  50.         }
  51.     }
  52. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top