Skip to content

Instantly share code, notes, and snippets.

@kaorun55
Created February 9, 2017 22:40
Show Gist options
  • Save kaorun55/373112ee4122fe9ee58b47a339bab9ec to your computer and use it in GitHub Desktop.
Save kaorun55/373112ee4122fe9ee58b47a339bab9ec to your computer and use it in GitHub Desktop.
public IEnumerator Save(string filename, byte[] buffer)
{
#if UNITY_UWP
var task = Task.Run(async () =>
{
StorageFolder folder = await GetStorageFolder();
var file = await folder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
using (var stream = await file.OpenStreamForWriteAsync())
{
await stream.WriteAsync(buffer, 0, buffer.Length);
}
});
yield return new WaitWhile(() => task.Wait(1));
// ファイルリストを更新
yield return Update();
#else
yield return new WaitForEndOfFrame();
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment