12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using UnityEngine;
- using System.Collections;
- using System.IO;
- public class DownloadBundleDevice : MonoBehaviour
- {
- private static string[] _files =new []{ "default_background", "default_hd" , "default_scenery", "default_sd", "default_shd" };
- private static string Platform
- {
- get
- {
- #if UNITY_ANDROID
- return "Android";
- #endif
- #if UNITY_IPHONE
- return "iPhone";
- #endif
- return "";
- }
- }
- public static void Extract()
- {
- var path = Application.persistentDataPath.TrimEnd('/') + "/" + Platform;
- if (!Directory.Exists(path))
- {
- Directory.CreateDirectory(path);
- }
- foreach (var file in _files)
- {
- var data = Resources.Load<TextAsset>(Platform + "/" + file).bytes;
- var manifest = Resources.Load<TextAsset>(Platform + "/" + file + ".bytes").text;
-
- File.WriteAllBytes(path + "/" + file + ".unity3d", data);
-
- File.WriteAllText(path + "/" + file + ".unity3d.manifest", manifest);
- Debug.Log("Path " + path);
- //Debug.Log(path + "/" + file + ".unity3d");
- }
- /*for (int i = 0; i < _files.Length; i++)
- {
-
- }*/
- }
- }
|