Created
October 22, 2021 13:10
-
-
Save LosoncziTamas/03c2bd1371034485313363656da05065 to your computer and use it in GitHub Desktop.
Unpacking file from streamingAssetsPath & moving to persistentDataPath on Android.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.IO; | |
| using UnityEngine; | |
| public static class StreamingAssetsUtility | |
| { | |
| public static string UnpackStreamingAssetAndroid(string fileName) | |
| { | |
| var sourcePath = Path.Combine(Application.streamingAssetsPath, fileName); | |
| var reader = new WWW(sourcePath); | |
| while (!reader.isDone){} | |
| var destPath = Path.Combine(Application.persistentDataPath, fileName); | |
| File.WriteAllBytes(destPath, reader.bytes); | |
| return destPath; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment