Skip to content

Instantly share code, notes, and snippets.

@LosoncziTamas
Created October 22, 2021 13:10
Show Gist options
  • Select an option

  • Save LosoncziTamas/03c2bd1371034485313363656da05065 to your computer and use it in GitHub Desktop.

Select an option

Save LosoncziTamas/03c2bd1371034485313363656da05065 to your computer and use it in GitHub Desktop.
Unpacking file from streamingAssetsPath & moving to persistentDataPath on Android.
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