Skip to content

FileBrowser.WaitForSave/LoadDialog coroutine returns too early on Android #107

@jaoreir

Description

@jaoreir

Description of the bug

When using FileBrowser.WaitForSaveDialog(...) or FileBrowser.WaitForLoadDialog(...) coroutines, they end before FileBrowser.Success becomes true on android, causing the example coroutine in the readme of the project to not work properly.

Reproduction steps

    IEnumerator TestRoutine()
    {
        yield return FileBrowser.WaitForSaveDialog(
            FileBrowser.PickMode.Files,
            false,
            null,
            "save.txt",
            "TITLE",
            "Save"
        );
        Debug.Log($"FileBrowser.Success: {FileBrowser.Success}");
        if (FileBrowser.Success) // This never becomes true
        {
            string filePath = FileBrowser.Result[0];
            Debug.Log($"File path: {filePath}");
            FileBrowserHelpers.WriteTextToFile(filePath, "test file content 123123");
            Debug.Log("Saved");
        }
    }

If I additionally wait for FileBrowser.Success to become true, the rest of the code works fine, but now if the user clicks the "Cancel" button, the coroutine would get stuck waiting forever.

    IEnumerator TestRoutine()
    {
        yield return FileBrowser.WaitForSaveDialog(
            FileBrowser.PickMode.Files,
            false,
            null,
            "save.txt",
            "TITLE",
            "Save"
        );
        yield return new WaitUntil(() => FileBrowser.Success); // This line is needed to actually wait for the dialog to finish
        Debug.Log($"FileBrowser.Success: {FileBrowser.Success}");
        if (FileBrowser.Success)
        {
            string filePath = FileBrowser.Result[0];
            Debug.Log($"File path: {filePath}");
            FileBrowserHelpers.WriteTextToFile(filePath, "test file content 123123");
            Debug.Log("Saved");
        }
    }

Platform specs

  • Unity version: 2022.3.50f1
  • Platform: Android
  • Device: Samsung Galaxy A55 5G
  • How did you download the plugin: github repo link in manifest.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions