コード例 #1
0
    private void modifyList(bool building)
    {
        //clear the list
        for (int i = 0; i < transform.childCount; i++)
        {
            Destroy(transform.GetChild(i).gameObject);
        }

        //done if leaving the menu
        if (!building)
        {
            return;
        }

        if (Directory.Exists(GameManager.savePath))
        {
            string[] saves = Directory.GetFiles(GameManager.savePath);
            foreach (string save in saves)
            {
                int    start     = save.LastIndexOf(Path.DirectorySeparatorChar) + 1;
                int    end       = save.LastIndexOf('.');
                string sani_save = save.Substring(start, end - start);
                GameSummary.Create(GetComponent <RectTransform> (), GameManager.instance.loadSave(sani_save));
                Debug.Log("Loaded " + sani_save);                  //DEBUG
            }
        }
        else
        {
            //TODO display special graphic for no saves
        }

        // orient the window on the first save, ifex
        targetChild = 0;
        if (transform.childCount > 0)
        {
            calcTargetX();
        }
    }