簡體   English   中英

Unity iOS 內置 Xcode 無法從 Firebase 存儲寫入下載的圖像

[英]Unity iOS build in Xcode cannot write downloaded images from Firebase Storage

在 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 項目,沒有看到運行時文件夾(即使在顯示隱藏項目之后)

知道如何解決這個問題嗎?

解決方案當然不明顯。

顯然,我需要做的就是將file:///添加到 savePath 變量中,如下所示:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM