Пример #1
0
    string FillList()
    {
        for (int i = 0; i < listContent.childCount; i++)
        {
            Destroy(listContent.GetChild(i).gameObject);
        }
#if UNITY_IOS || UNITY_ANDROID
        string[] paths =
            Directory.GetFiles(Application.persistentDataPath, "*.map");
#else
        string[] paths =
            Directory.GetFiles(Path.Combine(Application.dataPath, "maps"), "*.map");
#endif
        Array.Sort(paths);
        string firstFile = "";
        for (int i = 0; i < paths.Length; i++)
        {
            SaveLoadItem item = Instantiate(itemPrefab);
            item.menu    = this;
            item.MapName = Path.GetFileNameWithoutExtension(paths[i]);
            if (string.IsNullOrEmpty(firstFile))
            {
                firstFile = item.MapName;
            }
            item.transform.SetParent(listContent, false);
        }
        return(firstFile);
    }
Пример #2
0
        public IEnumerator MapNameIsSetCorrectly()
        {
            GameObject   obj1 = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Prefabs/UI/Save Load Item"));
            SaveLoadItem sli  = obj1.GetComponent <SaveLoadItem>();

            sli.MapName = "Map1";

            yield return(new WaitForSeconds(0.1f));

            Assert.AreEqual(sli.MapName, "Map1");

            GameObject.Destroy(obj1);
            GameObject.Destroy(sli);
        }
Пример #3
0
 void FillList()
 {
     for (int i = 0; i < listContent.childCount; i++)
     {
         Destroy(listContent.GetChild(i).gameObject);
     }
     string[] paths = Directory.GetFiles(Application.persistentDataPath, "*.map");
     Array.Sort(paths);
     for (int i = 0; i < paths.Length; i++)
     {
         SaveLoadItem item = Instantiate(itemPrefab);
         item.menu    = this;
         item.MapName = Path.GetFileNameWithoutExtension(paths[i]);
         item.transform.SetParent(listContent, false);
     }
 }
        public IEnumerator CorrectMapLoading()
        {
            SceneManager.LoadScene("Scene", LoadSceneMode.Single);
            yield return(new WaitForSeconds(1.0f));

            goA = SceneManager.GetActiveScene().GetRootGameObjects();
            GameObject   go  = goA[3].transform.Find("Save Load Menu").gameObject;
            SaveLoadMenu slm = go.GetComponent <SaveLoadMenu>();
            GameObject   go2 = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Prefabs/UI/Save Load Item"));
            SaveLoadItem sli = go2.GetComponent <SaveLoadItem>();

            sli.MapName    = "test16";
            sli.menu       = slm;
            slm.itemPrefab = sli;
            sli.Select();
            slm.hexGrid = goA[1].GetComponent <HexGrid>();
            slm.Open(true);
            slm.Action();
            slm.Open(false);
            slm.Action();
            string[] paths = Directory.GetFiles(Application.persistentDataPath, "*.map");
            bool     b     = false;

            for (int i = 0; i < paths.Length; i++)
            {
                if (Path.GetFileNameWithoutExtension(paths[i]) == sli.MapName)
                {
                    b = true;
                    break;
                }
            }

            Assert.IsTrue(b);

            foreach (GameObject g in goA)
            {
                GameObject.Destroy(g);
            }
            GameObject.Destroy(go);
            GameObject.Destroy(slm);
            GameObject.Destroy(go2);
            GameObject.Destroy(sli);
            SceneManager.UnloadScene("Scene");
        }
Пример #5
0
    void FillList()
    {
        for (int i = 0; i < listContent.childCount; i++)
        {
            Destroy(listContent.GetChild(i).gameObject);
        }

        string[] paths =
            Directory.GetFiles(Application.dataPath + "/RoomsWorkingDir2", "*.txt", SearchOption.AllDirectories);

        Array.Sort(paths);

        for (int i = 0; i < paths.Length; i++)
        {
            SaveLoadItem item = Instantiate(itemPrefab);
            item.menu    = this;
            item.Path    = paths[i];
            item.MapName = Path.GetFileNameWithoutExtension(paths[i]);
            item.transform.SetParent(listContent, false);
        }
    }
Пример #6
0
 public void SelectItem(SaveLoadItem selected)
 {
     nameInput.text = selected.MapName;
 }