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;

      [SerializeField]
      Text Result;

      string currentValue = string.Empty;

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

         // show picker
         picker.Show(currentValue, ValueSelected, Canceled);
      }

      void ValueSelected(string value)
      {
         currentValue = value;
         Debug.Log("value: " + value);
      }

      void Canceled()
      {
         Debug.Log("canceled");
      }

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

         // show picker
         picker.Show(currentValue, ShowValueSelected, ShowCanceled);
      }

      void ShowValueSelected(string value)
      {
         currentValue = value;
         Result.text = "Value: " + value;
      }

      void ShowCanceled()
      {
         Result.text = "Canceled";
      }
   }
}