public void LoadColor() { //Checks if the file exists if (File.Exists(Application.dataPath + "/../" + "/ColorPreference" + "/ColorPreference")) { BinaryFormatter formater = new BinaryFormatter(); //Open file FileStream stream = new FileStream(Application.dataPath + "/../" + "/ColorPreference" + "/ColorPreference", FileMode.Open); //Obtain the saved data ColorTrackerData theColorTrackerData = formater.Deserialize(stream) as ColorTrackerData; stream.Close(); BaseBaseColor = new Color(theColorTrackerData.BaseBaseColor[0], theColorTrackerData.BaseBaseColor[1], theColorTrackerData.BaseBaseColor[2], theColorTrackerData.BaseBaseColor[3]); BaseEmissionColor = new Color(theColorTrackerData.BaseEmissionColor[0], theColorTrackerData.BaseEmissionColor[1], theColorTrackerData.BaseEmissionColor[2], theColorTrackerData.BaseEmissionColor[3]); TrimBaseColor = new Color(theColorTrackerData.TrimBaseColor[0], theColorTrackerData.TrimBaseColor[1], theColorTrackerData.TrimBaseColor[2], theColorTrackerData.TrimBaseColor[3]); TrimEmissionColor = new Color(theColorTrackerData.TrimEmissionColor[0], theColorTrackerData.TrimEmissionColor[1], theColorTrackerData.TrimEmissionColor[2], theColorTrackerData.TrimEmissionColor[3]); EngineBaseColor = new Color(theColorTrackerData.EngineBaseColor[0], theColorTrackerData.EngineBaseColor[1], theColorTrackerData.EngineBaseColor[2], theColorTrackerData.EngineBaseColor[3]); EngineEmissionColor = new Color(theColorTrackerData.EngineEmissionColor[0], theColorTrackerData.EngineEmissionColor[1], theColorTrackerData.EngineEmissionColor[2], theColorTrackerData.EngineEmissionColor[3]); ShieldColor = new Color(theColorTrackerData.ShieldColor[0], theColorTrackerData.ShieldColor[1], theColorTrackerData.ShieldColor[2], theColorTrackerData.ShieldColor[3]); } }
public void SaveColor() { BinaryFormatter formater = new BinaryFormatter(); //Create file FileStream stream = new FileStream(Application.dataPath + "/../" + "/ColorPreference" + "/ColorPreference", FileMode.Create); //The whole ship's information ColorTrackerData theColorTrackerData = new ColorTrackerData(this); //Write to file formater.Serialize(stream, theColorTrackerData); stream.Close(); }