How do I convert list of files from Dir.Getfiles into string array for GUI.SelectionGrid?

string[] fileList = Directory.GetFiles(DirPath, "*.meh");
public int selGridInt = 0;
void OnGUI() {
    selGridInt = GUI.SelectionGrid(new Rect(25, 25, 100, 30), selGridInt, fileList, 2);
   }
}

This should work but it doesnt? It makes no sense to me.

I think you have to break the path apart from the search spec and supply it separately.

See the two argument version of Dir.Getfiles that I’m using below, and it works fine.

using UnityEngine;
using System.Collections;

public class GUISelectionGrid : MonoBehaviour
{
    string[] theList;

    void Start()
    {
        theList = System.IO.Directory.GetFiles ("Assets/", "*.meta");
    }

    void OnGUI()
    {
        GUI.SelectionGrid (new Rect (0, 0, Screen.width, Screen.height),
                          2, theList, 3);
    }
}

Kurt-Dekker

Thanks, still wont work for me but I did it ab it differently:

this.fileList = Directory.GetFiles(Application.persistentDataPath, "*.meh");
    for (int iFile = 0; iFile < this.fileList.Length; iFile++)
    {
        this.fileList[iFile] = new FileInfo(this.fileList[iFile]).Name;
    }