FolderDialog

Options

  • Directory Tree View DirectoryTreeView

    DirectoryTreeView widget.

  • Ok Button Button

    Button to close dialog.

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

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

             [SerializeField]
             Text Result;

             string currentValue = string.Empty;

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

                     // show picker
                     var value = await picker.Show(currentValue);
         if (value.Success)
         {
            currentValue = value;
            Debug.Log("value: " + value);
         }
         else
         {
            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";
             }
     }
}