using LitJson; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; public class CeShi1 : MonoBehaviour { // Start is called before the first frame update public Data_PlayerAttributes dataPA; private int myrandom; private List playerID = new List(); private int indexlist; private List dataPlayerAttributesList = new List(); void Start() { } // Update is called once per frame void Update() { XXX(); } public void XXX() { myrandom = UnityEngine.Random.Range(0, 2); //随机下标 if (myrandom == 0) { dataPA = JsonMapper.ToObject(JsonRead("cel_Label")); } else { dataPA = JsonMapper.ToObject(JsonRead("cel_Label 1")); } if (!playerID.Contains(dataPA.data.message.data2.id)) { playerID.Add(dataPA.data.message.data2.id);//得到了两个数字 88888 213123213 dataPlayerAttributesList.Add(dataPA); } for (int i = 0; i < dataPlayerAttributesList.Count; i++) { if (dataPlayerAttributesList[i].data.message.data2.id.Contains(dataPA.data.message.data2.id)) { dataPlayerAttributesList[i] = dataPA; } Debug.Log(dataPlayerAttributesList[i].data.message.data2.id + " " + i); } // Debug.Log(dataPlayerAttributesList.Count); //for (int i = 0; i < playerID.Count; i++) //{ // if (playerID[i] == dataPA.data.message.data2.id) //1==data || 2==data // { // indexlist = i; // // dataPlayerAttributesList[indexlist] = dataPA; // //Debug.Log(playerID[i]+" "+i); // } //} } public string JsonRead(string name) { string json = ""; TextAsset text = Resources.Load("Jsons/" + name); json = text.text; if (string.IsNullOrEmpty(json)) return null; return json; } }