public Component ReadFromJson(IResMgr resmgr, GameObject node, MyJson.JsonNode_Object json, DelayProcess dp) { SkinnedMeshRenderer c = node.GetComponent(comptype) as SkinnedMeshRenderer; if (c == null)//这就可能了 { c = node.AddComponent <SkinnedMeshRenderer>(); } //mats var mats = json["mats"].AsList(); Material[] rmats = new Material[mats.Count]; for (int i = 0; i < mats.Count; i++) { string hashname = mats[i].AsString(); rmats[i] = resmgr.GetMat(hashname); } c.materials = rmats; //bound var center = StringHelper.ToVector3(json["center"].AsString()); var size = StringHelper.ToVector3(json["size"].AsString()); c.localBounds = new Bounds(center, size); //mesh var mesh = resmgr.GetMesh(json["mesh"].AsString()); c.sharedMesh = mesh; //延迟恢复 if (json.ContainsKey("rootboneobj")) { dp.delayCall += () => { c.rootBone = dp.mapObjs[json["rootboneobj"].AsInt()].transform; }; } if (json.ContainsKey("boneobjs")) { dp.delayCall += () => { var array = json["boneobjs"] as MyJson.JsonNode_Array; List <Transform> bones = new List <Transform>(); foreach (var b in array) { bones.Add(dp.mapObjs[b.AsInt()].transform); } c.bones = bones.ToArray(); }; } return(c); }
public Component ReadFromJson(IResMgr resmgr, GameObject node, MyJson.JsonNode_Object json, DelayProcess dp) { MeshRenderer c = node.GetComponent(comptype) as MeshRenderer; if (c == null)//这就可能了 c = node.AddComponent<MeshRenderer>(); var mats = json["mats"].AsList(); Material[] rmats = new Material[mats.Count]; for (int i = 0; i < mats.Count; i++) { string hashname = mats[i].AsString(); rmats[i] = resmgr.GetMat(hashname); } c.materials = rmats; return c; }
public Component ReadFromJson(IResMgr resmgr, GameObject node, MyJson.JsonNode_Object json, DelayProcess dp) { SkinnedMeshRenderer c = node.GetComponent(comptype) as SkinnedMeshRenderer; if (c == null)//这就可能了 c = node.AddComponent<SkinnedMeshRenderer>(); //mats var mats = json["mats"].AsList(); Material[] rmats = new Material[mats.Count]; for (int i = 0; i < mats.Count; i++) { string hashname = mats[i].AsString(); rmats[i] = resmgr.GetMat(hashname); } c.materials = rmats; //bound var center = StringHelper.ToVector3(json["center"].AsString()); var size = StringHelper.ToVector3(json["size"].AsString()); c.localBounds = new Bounds(center, size); //mesh var mesh = resmgr.GetMesh(json["mesh"].AsString()); c.sharedMesh = mesh; //延迟恢复 if (json.ContainsKey("rootboneobj")) { dp.delayCall += () => { c.rootBone = dp.mapObjs[json["rootboneobj"].AsInt()].transform; }; } if (json.ContainsKey("boneobjs")) { dp.delayCall += () => { var array = json["boneobjs"] as MyJson.JsonNode_Array; List<Transform> bones = new List<Transform>(); foreach (var b in array) { bones.Add(dp.mapObjs[b.AsInt()].transform); } c.bones = bones.ToArray(); }; } return c; }
public Component ReadFromJson(IResMgr resmgr, GameObject node, MyJson.JsonNode_Object json, DelayProcess dp) { MeshRenderer c = node.GetComponent(comptype) as MeshRenderer; if (c == null)//这就可能了 { c = node.AddComponent <MeshRenderer>(); } var mats = json["mats"].AsList(); Material[] rmats = new Material[mats.Count]; for (int i = 0; i < mats.Count; i++) { string hashname = mats[i].AsString(); rmats[i] = resmgr.GetMat(hashname); } c.materials = rmats; return(c); }