在 Unity Editor 中,該應用程式與 Firebase 存盤配合良好。影像被下載和使用。當我們為 iOS 構建 Unity 應用程式時,它在嘗試從 Firebase 存盤下載影像時出錯。我認為,這是寫入權限的問題,我不知道如何從 Unity 代碼中解決它
做了什么
- 清理構建檔案夾
- 更新到最新的 Firebase 軟體包
- 請參閱這些 SO 問題:
- Firebase 存盤下載到本地檔案錯誤
- 影像未從 Firebase 存盤下載
- 從 Firebase 存盤下載時出錯
- 這些執行緒沒有使用 Unity,我不知道如何將它們應用于手頭的問題
代碼
string savePath = Application.persistentDataPath "/" data.banner;
StorageReference storageRef = storage.GetReference(data.banner);
Task task = storageRef.GetFileAsync(savePath, new StorageProgress<DownloadState>((DownloadState state) => {
GetComponent<DatabaseManager>().UpdateProgress(state.BytesTransferred, state);
}), CancellationToken.None);
task.ContinueWithOnMainThread(resultTask => {
if (!resultTask.IsFaulted && !resultTask.IsCanceled && resultTask.IsCompleted) {
floorCounter ;
if (floorCounter == floors.Count) {
isFloorComplete = true;
}
} else {
Debug.Log(resultTask.Exception.ToString());
errorCaught = true;
return;
}
});
錯誤
System.AggregateException: One or more errors occurred. ---> Firebase.Storage.StorageException: An unknown error occurred
--- End of inner exception stack trace ---
---> (Inner Exception #0) Firebase.Storage.StorageException: An unknown error occurred<---
<>c__DisplayClass3_1:<DownloadImages>b__3(Task)
System.Action`1:Invoke(T)
Firebase.Extensions.<ContinueWithOnMainThread>c__AnonStorey1:<>m__0()
System.Func`1:Invoke()
Firebase.<RunAsync>c__AnonStorey1`1:<>m__0()
System.Action:Invoke()
Firebase.ExceptionAggregator:Wrap(Action)
Firebase.Dispatcher:PollJobs()
Firebase.Platform.FirebaseHandler:Update()
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
這些錯誤沒有幫助,更糟糕的是,我不知道如何找到Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35). 我打開了 Xcode 專案,但看不到 Runtime 檔案夾(即使在顯示隱藏專案之后)
知道如何解決這個問題嗎?
uj5u.com熱心網友回復:
解決方案當然不是顯而易見的。
顯然,我需要做的就是添加file:///到 savePath 變數,如下所示:
string savePath = "file:///" Application.persistentDataPath "/" data.banner
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/393339.html
