Custom filebrowser for Unity

I had a project recently, that used the WinForms filebrowser plugin for Unity. Then I was tasked to port that project to android and ran into issues with the filebrowser. I could of used one of the premade filebrowsers from Asset store, but they were all too advanced for my needs. So I decided to make simple version myself. Feel free to use it for whatever you need it for.

using UnityEngine;
using UnityEngine.UI;
using System.IO;
using System.Collections;
using System.Collections.Generic;

public class FileSelector : MonoBehaviour
{
    [SerializeField]
    private UnityEngine.UI.InputField m_inputField;

    [SerializeField]
    private GameObject m_fileBrowser;

    [SerializeField]
    private VerticalLayoutGroup m_layoutGroup;

    [SerializeField]
    private Scrollbar m_verticalScroll;

    [SerializeField]
    private UnityEngine.UI.Button m_folderButton;

    [SerializeField]
    private UnityEngine.UI.Button m_upperFolderButton;

    //our current location
    private string m_curFolderPath;


    private void Start()
    {
        Initialize();
    }

    private void Initialize()
    {
        //Init the file browser, show root folder based on platform.
#if UNITY_STANDALONE
        m_curFolderPath = @"C:\";
#elif UNITY_ANDROID
        m_curFolderPath = @"storage/";
#endif
        UpdateFolderView();
    }

    //refresh folder view, show subfolders of the current folder
    private void UpdateFolderView()
    {
        print(m_curFolderPath);
        m_inputField.text = m_curFolderPath;
       
        //clear view
        for(int i = 0; i < m_layoutGroup.transform.childCount; i++)
        {
            Destroy(m_layoutGroup.transform.GetChild(i).gameObject);
        }
        m_upperFolderButton.enabled = false;
        //get new subfolders
        StartCoroutine("GetSubFolders");
        StartCoroutine("GetTextFilesInFolder");
    }

    private IEnumerator GetSubFolders()
    {
        string[] subFolders = Directory.GetDirectories(m_curFolderPath);

        int index = 0;
        while(index < subFolders.Length)
        {
            print(subFolders[index]);
            CreateFolderButton(subFolders[index]);
            index++;
            yield return null;
        }
        
        yield return null;

        m_verticalScroll.value = 1;
        m_upperFolderButton.enabled = true;
    }

    private IEnumerator GetTextFilesInFolder()
    {
        List<string> txtFiles = new List<string>();

        txtFiles.AddRange( Directory.GetFiles(m_curFolderPath, "*.txt") );

        int index = 0;
        while (index < txtFiles.Count)
        {
            print(txtFiles[index]);
            CreateFileButton(txtFiles[index]);
            index++;
            yield return null;
        }

        yield return null;

        m_verticalScroll.value = 1;
        m_upperFolderButton.enabled = true;
    }

    public void MoveUp()
    {
        m_curFolderPath = Directory.GetParent(m_curFolderPath).FullName;
        UpdateFolderView();
    }

    //Creates buttons for folders
    private void CreateFolderButton(string folderPath)
    {
        GameObject button = GameObject.Instantiate(m_folderButton.gameObject);
        button.transform.SetParent(m_layoutGroup.transform);
        button.GetComponent<RectTransform>().localScale = Vector3.one;
        button.transform.GetChild(0).GetComponent<UnityEngine.UI.Text>().text = Path.GetFileName(folderPath);

        //bind event to button click, changes currentpath to clicked folder
        button.GetComponent<UnityEngine.UI.Button>().onClick.AddListener(() => { m_curFolderPath = folderPath; UpdateFolderView(); });
    }

    //Creates buttons for files
    private void CreateFileButton(string filePath)
    {
        GameObject button = GameObject.Instantiate(m_folderButton.gameObject);
        button.transform.SetParent(m_layoutGroup.transform);
        button.GetComponent<RectTransform>().localScale = Vector3.one;
        button.transform.GetChild(0).GetComponent<UnityEngine.UI.Text>().text = Path.GetFileName(filePath);
        button.GetComponent<UnityEngine.UI.Button>().onClick.AddListener(() => { m_inputField.text = filePath; });
    }
}

Here are few images on how to set it up. Buttons are just standard buttons that are made into prefabs, their functionality is set in the code.