123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class ModelManager : Singleton<ModelManager>
- {
-
- public Dictionary<int, ModelList> modellist = new Dictionary<int, ModelList>();
-
- public GameObject materialLibrary;
- private List<ModelList> Models;
- public void init(string message)
- {
- GameManager.Instance.text.text = " 获取素材列表";
- JObject jObject = JObject.Parse(message);
- string data = jObject["data"].ToString();
- JObject dataObject = JObject.Parse(data);
- string single = dataObject["single"].ToString();
- string library = dataObject["library"].ToString();
- string combination = dataObject["combination"].ToString();
- materialLibrary = new GameObject("MaterailLibrary");
-
- AddDicModelList(single);
- AddDicModelList(library);
- AddDicModelList(combination);
-
-
-
-
- }
- private void AddDicModelList(string message)
- {
-
- if (!string.IsNullOrWhiteSpace(message))
- {
- Models = JsonConvert.DeserializeObject<List<ModelList>>(message);
- int len = Models.Count;
- for (int i = 0; i < len; i++)
- {
- if (Models.Count - 1 < len && (Models[i].type == 0))
- Models.Remove(Models[i]);
- }
- Debug.Log(Models.Count + " AddDicModelList " + message);
- for (int i = 0; i < Models.Count; i++)
- {
- modellist.Add(Models[i].id, Models[i]);
- StartModelList(Models[i], materialLibrary);
-
- }
- }
- }
-
-
-
-
-
- public void StartModelList( ModelList modelList, GameObject parent )
- {
- modelList.materalLibrary = parent.transform;
- for (int j = 0; j < modelList.materialList.Count; j++)
- {
- modelList.materialList[j].updateTime = modelList.updateTime;
- Debug.Log("modelList.Model==>"+ modelList.Model.name);
- modelList.materialList[j].init(modelList.Model);
-
- }
- }
-
-
-
-
-
- public ModelList GetModelList(int id)
- {
-
- if (modellist.ContainsKey(id))
- return (ModelList)modellist[id].Clone();
- else
- return null;
- }
-
- private void DownLoadModel(ModelList list)
- {
- for (int i = 0; i < list.materialList.Count; i++)
- {
- if (list.materialList[i].Model != null)
- Debug.Log(" 检测下载 " + list.materialList[i].name);
- }
- }
- }
|