我正在構建針對Windows Store 8.1的Unity遊戲,並且需要將遊戲進度保存在獨立存儲中。但在訪問本地存儲使用「等待」經營者給我這個錯誤在獨立存儲中保存Unity遊戲的進度
'await' requires that the type 'Windows.Foundation.IAsyncOperation<Windows.Storage.StorageFile>' have a suitable GetAwaiter method. Are you missing a using directive for 'System'?
有沒有一種方法,我可以用「等待」經營者不知何故?
我想如果我在將項目導出到Windows 8.1後生成的解決方案中實現我的Save方法,它將正常工作。麻煩是我不確定如何訪問主解決方案中的統一腳本的變量和方法(在保存遊戲時需要)。
任何人都可以幫助任何這些方法,或者如果有更好的方法嗎?
編輯: 這裏是我使用的代碼:
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
}
}
我不認爲你會得到一個答案,除非你發佈代碼,再現問題 – Mick 2014-09-02 02:44:40
@米克增加了代碼 – Tehreem 2014-09-02 03:43:36