【发布时间】:2022-01-23 10:13:57
【问题描述】:
在 Unity 编辑器中,该应用可以很好地与 Firebase 存储配合使用。图像被下载并使用。当我们为 iOS 构建 Unity 应用程序时,它在尝试从 Firebase 存储下载图像时出错。我认为,这是写权限的问题,我不知道如何从 Unity 代码中解决它
做了什么
- 清理构建文件夹
- 更新到最新的 Firebase 软件包
- 请参阅这些 SO 问题:
- Firebase Storage download to local file error
- Images not downloading from Firebase Storage
- Error when downloading from Firebase storage
- 这些线程没有使用 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 文件夹(即使在显示隐藏项之后)
知道如何解决这个问题吗?
【问题讨论】:
标签: ios xcode firebase unity3d firebase-storage