FileDialog

If you want to open directories and select files with a single click instead of the double-click just move FileListView.DefaultItem DoubleClick callback to OnClick event.

../_images/FileListView-single-click.png

Options

  • File List View FileListView

    FileListView.

  • Confirm Dialog PickerBool

    Dialog to get confirmation if Request Confirmation If File Exists enabled.

  • FilenameInput InputField

    Input for the filename.

  • OkButton Button

    Button to close dialog.

  • FileShouldExists bool

    Selected file should exists.

  • Request Confirmation If File Exists bool

    Show Confirm Dialog if file exists.

Code examples

namespace UIWidgets.Examples
{
    using UIWidgets;
    using UnityEngine;
    using UnityEngine.UI;

    /// <summary>
    /// Test FileDialog.
    /// </summary>
    public class TestFileDialog : MonoBehaviour
    {
        [SerializeField]
        FileDialog PickerTemplate;

        string currentValue = string.Empty;

        /// <summary>
        /// Show picker async and log selected value.
        /// </summary>
        async public void Test()
        {
            // create picker by template
            var picker = PickerTemplate.Clone();

            // show picker
            var value = await picker.ShowAsync(currentValue);
            if (value.Success)
            {
                currentValue = value;
                Debug.Log("value: " + value);
            }
            else
            {
                Debug.Log("canceled");
            }
        }
    }
}