Пример #1
0
    public void Save()
    {
        List <GameObject> createdbuildings = buildingPlacement.getCreatedBuildings();
        // Save Data in string
        string saveData = null;

        foreach (GameObject createdbuilding in createdbuildings)
        {
            // string buildingType = createdbuilding.name;
            // str = str.Substring(0, 1);
            string[] contents = new string[] {
                "" + createdbuilding.name,
                "" + createdbuilding.name.Substring(0, 1),
                "" + createdbuilding.transform.localPosition.x,
                "" + createdbuilding.transform.localPosition.y,
                "" + createdbuilding.transform.localPosition.z
            };
            string saveAttributes = string.Join(ATTRIBUTE_SEPERATOR, contents);
            if (saveData != null && saveData != "")
            {
                string[] saveObjects = new string [] { saveData, saveAttributes };
                saveData = string.Join(OBJECT_SEPERATOR, saveObjects);
            }
            else
            {
                saveData = saveAttributes;
            }

            File.WriteAllText(Application.dataPath + "/save.txt", saveData);
        }
    }