using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; public class ArmorShop : MonoBehaviour { public GameObject PlayerOnS; public Sprite[] BodyIcon; public Sprite[] HeadIcon; public Sprite[] SwordIcon; public List TxtS; public List TxtH; public GameObject ArmorData; public GameObject Profile; public List Profiles; public GameObject ProfileH; public List ProfilesH; public TMP_Text MettalCount; int Lan; private List HaveHead; private List HaveSword; public TMP_Text MC; public int HeadID; public int SwordID; bool CanBuy; void SaveS() { string json = JsonUtility.ToJson(new Serialization(HaveSword)); PlayerPrefs.SetString("HaveSw", json); PlayerPrefs.Save(); Debug.Log(HaveSword.Count); } void LoadS() { if (PlayerPrefs.HasKey("HaveSw")) { string json = PlayerPrefs.GetString("HaveSw"); HaveSword = JsonUtility.FromJson>(json).List; } else { PlayerPrefs.SetString("HaveSW", ""); Debug.Log(HaveSword); } } void SaveH() { string json = JsonUtility.ToJson(new Serialization(HaveHead)); PlayerPrefs.SetString("HaveHe", json); PlayerPrefs.Save(); Debug.Log(HaveHead.Count); } void LoadH() { if (PlayerPrefs.HasKey("HaveHe")) { string json = PlayerPrefs.GetString("HaveHe"); HaveHead = JsonUtility.FromJson>(json).List; } else { Debug.Log(HaveHead); } } [System.Serializable] private class Serialization { public List List; public Serialization(List list) { this.List = list; } public List ToList() { return List; } } // Start is called before the first frame update void Start() { LoadH(); LoadS(); RebornDataScript DataF = ArmorData.GetComponent(); Lan = PlayerPrefs.GetInt("LanguageID"); if (HaveSword == null) { Debug.Log("AdS"); HaveSword = new List(0); SaveS(); } if (HaveHead == null) { HaveHead = new List(0); SaveH(); Debug.Log("AdH"); } for (int i = 0; i < 7; i++) { int num = i; Profiles.Add(Instantiate(Profile, Profile.transform.parent.parent)); Profiles[i].GetComponent().position -= new Vector3(-(i)%2*6, i * 1.5f +((i+1)%2*1.5f), 0); Profiles[i].transform.GetComponentInChildren().gameObject.transform.GetChild(0).GetComponentInChildren().sprite = DataF.Sword[i]; TxtS.Add(Profiles[i].transform.GetChild(0).transform.GetChild(1).transform.GetComponentInChildren()); switch(Lan) { case 0: Profiles[i].transform.GetChild(1).GetComponent().text = DataF.SwordLan0[i]; break; case 1: Profiles[i].transform.GetChild(1).GetComponent().text = DataF.SwordLan1[i]; break; } Profiles[i].transform.GetChild(2).GetComponent().text = DataF.SwordAtack[i].ToString(); //print(starts.IndexOf(starts[i])); //Open.Add(new Button.ButtonClickedEvent { }); //Open[i].AddListener(() => PlayOpen(num)); //print(i); Profiles[i].transform.GetChild(0).GetComponentInChildren