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

Using FileDialog.

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";
      }
   }
}