小编Sea*_*aMe的帖子

协程中的值为真后无法返回字符串

我在运行这个协程时遇到了问题。它一直吐出一个错误,说它不能将 WaitUntil 转换为字符串,当我将 WaitUntil 添加到返回类型时,它又吐出另一个说它无法返回。我已经尝试研究了几个小时,但无济于事。这是代码的片段:

     public string OpenSaveDialog(string Title, string OpenLocation, string[] AllowedExtentions)
     {
         OpenBtn.GetComponentInChildren<TMPro.TMP_Text>().text = "Save";
         TitleText.text = Title;
         AllowFileNameTyping = true;
         MultiSelect = false;

         LoadIntoExplorer(PathInput, AllowedExtentions);

         return StartCoroutine(WaitForFinish()); // Error here: Cannot implicitly convert type 'UnityEngine.Coroutine' to 'string'
     }

     IEnumerator<string> WaitForFinish()
     {
         yield return new WaitUntil(() => Done == true); // Error here: Cannot implicitly convert type 'UnityEngine.WaitUntil' to 'string'
         yield return FilePathsSelected[0];
     }
Run Code Online (Sandbox Code Playgroud)

c# return coroutine unity-game-engine

2
推荐指数
1
解决办法
378
查看次数

标签 统计

c# ×1

coroutine ×1

return ×1

unity-game-engine ×1