3

When I assigned a prefab in my vertical list of buttons to be clicked the example.json.meta files were also included in the list when I clicked play to see the UI.

how do I remove them?

here are the codes I used

void Start () {

    RectTransform rect = gameObject.GetComponent<RectTransform>();

    string filePath = Application.streamingAssetsPath;
    DirectoryInfo dir = new DirectoryInfo(filePath);
    FileInfo[] files = dir.GetFiles ("*.json");

    foreach (FileInfo file in files) {

        GameObject level = Instantiate(levelPrefab) as GameObject;
        level.name = Path.GetFileNameWithoutExtension(file.Name).ToString();
        level.transform.SetParent(GameObject.Find("Level/Panel/Scroll/LevelC").GetComponent<Transform>());
        level.GetComponentInChildren<Text>().text = level.name;
        string levelName = level.name;
        level.GetComponent<Button>().onClick.AddListener(() => OnClick(levelName));
        level.GetComponent<Button>().onClick.AddListener(() => menu.ShowMenu(GameObject.Find("Canvas/MainQue").GetComponent<Menu>()));
Matt Rowland
  • 4,575
  • 4
  • 25
  • 34
jess ruiz
  • 31
  • 2
  • I read [this](https://msdn.microsoft.com/en-us/library/8he88b63(v=vs.110).aspx) but are not pretty sure how to help you because I never used the `DirectoryInfo` class. – matiaslauriti Jul 09 '16 at 22:14
  • what is your settings in Project settings > editor > Version control > mode ? – Tiago Fabre Jul 09 '16 at 22:37
  • You need to filter the result in `files` as described in http://stackoverflow.com/questions/8443524/using-directory-getfiles-with-a-regex-in-c – Kay Jul 10 '16 at 07:34

0 Answers0