private void CreateNewFile() { if (parent != null) { DestroyImmediate(parent); } levelData = new BuildingReplacementData(); parent = new GameObject("Location Prefab"); }
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(); }
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); }