Windows ストア 8.1 を対象とした Unity ゲームを構築しており、ゲームの進行状況を分離ストレージに保存する必要があります。しかし、ローカルストレージにアクセスする際に「await」演算子を使用すると、このエラーが発生します
'await' requires that the type 'Windows.Foundation.IAsyncOperation<Windows.Storage.StorageFile>' have a suitable GetAwaiter method. Are you missing a using directive for 'System'?
どういうわけか「await」演算子を使用できる方法はありますか?
プロジェクトを Windows 8.1 にエクスポートした後に生成されたソリューションに Save メソッドを実装すると、正常に動作することがわかりました。問題は、メイン ソリューションの Unity スクリプトの変数とメソッド (ゲームの保存に必要) にアクセスする方法がわからないことです。
これらのアプローチのいずれかを手伝ってくれる人はいますか?
編集:これが私が使用しているコードです:
public async void save_game()
{
StorageFile destiFile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync("Merged.png", CreationCollisionOption.ReplaceExisting);
using (IRandomAccessStream stream = await destiFile.OpenAsync(FileAccessMode.ReadWrite))
{
//you can manipulate this stream object here
}
}