【问题标题】:Xcode 中的 Unity iOS 构建无法写入从 Firebase 存储下载的图像
【发布时间】:2022-01-23 10:13:57
【问题描述】:

在 Unity 编辑器中,该应用可以很好地与 Firebase 存储配合使用。图像被下载并使用。当我们为 iOS 构建 Unity 应用程序时,它在尝试从 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 文件夹(即使在显示隐藏项之后)

知道如何解决这个问题吗?

【问题讨论】:

    标签: ios xcode firebase unity3d firebase-storage


    【解决方案1】:

    解决方案肯定不明显。

    显然,我需要做的只是将file:/// 添加到 savePath 变量中,如下所示:

    string savePath = "file:///" + Application.persistentDataPath + "/" + data.banner
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-03
      • 2016-12-28
      • 1970-01-01
      • 2017-07-12
      • 2019-08-12
      • 1970-01-01
      • 2017-01-16
      • 2021-05-27
      相关资源
      最近更新 更多