コード例 #1
0
        private void CreateNewFile()
        {
            if (parent != null)
            {
                DestroyImmediate(parent);
            }

            levelData = new BuildingReplacementData();
            parent    = new GameObject("Location Prefab");
        }
コード例 #2
0
        public static void SaveBuildingFile(BuildingReplacementData interiorData, string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            StreamWriter writer   = new StreamWriter(path, false);
            string       saveData = SaveLoadManager.Serialize(interiorData.GetType(), interiorData);

            writer.Write(saveData);
            writer.Close();
        }
コード例 #3
0
        public static bool LoadBuildingFile(string path, out BuildingReplacementData buildingReplacement)
        {
            buildingReplacement = new BuildingReplacementData();

            if (string.IsNullOrEmpty(path))
            {
                Debug.LogError("Error: Trying to open file, but path is null or empty");
                return(false);
            }

            if (!File.Exists(path))
            {
                Debug.LogError("Error: Trying to open file at invalid path: " + path);
                return(false);
            }

            StreamReader reader = new StreamReader(path, false);

            buildingReplacement = (BuildingReplacementData)SaveLoadManager.Deserialize(typeof(BuildingReplacementData), reader.ReadToEnd());

            reader.Close();

            return(true);
        }