private void Start() { playerOutfitData = ES3.Load("PlayerOutfit", new PlayerOutfitData()); parts[1].sprite = hairStyles[playerOutfitData.hairStyleNumber]; // Загрузка определенной прически for (int i = 0; i < parts.Count; i++) // Придача цветов частям тела { parts[i].color = new Color(playerOutfitData.allColors[i, 0], playerOutfitData.allColors[i, 1], playerOutfitData.allColors[i, 2]); } }
public void Save() { colorsToSave = new Color[6]; colorsToSave[0] = Skin.color; colorsToSave[1] = Hair.color; for (int i = 0; i < Parts.Count; i++) { colorsToSave[i + 2] = Parts[i].color; } var playerOutfitData = new PlayerOutfitData(HairCounter, colorsToSave); var formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/playerOutfit.gina"; FileStream fileStream = new FileStream(path, FileMode.Create); formatter.Serialize(fileStream, playerOutfitData); fileStream.Close(); PlayerPrefs.SetString("PlayerName", inputName.text); PlayerPrefs.SetInt("isSaved", 1); PlayerPrefs.Save(); ES3.Save("PlayerOutfit", playerOutfitData); // var allParts = new List<SpriteRenderer>(); // allParts.Add(Skin); // allParts.Add(Hair); // foreach (var part in Parts) // { // allParts.Add(part); // } // ES3.Save("PlayerOutfit", allParts); }