using System.Collections; using System.Collections.Generic; using UnityEngine; public class World2 : MonoBehaviour { // // Start is called before the first frame update // void Start() // { // loadMap(); // } // // // Update is called once per frame // void Update() // { // // } // // public void loadMap() // { // //TextAsset ta = OnDemandLoader.getDataFile(0);// Resources.Load("data/0") as TextAsset; // Packet pkt = OnDemandLoader.getDataFile(1);//new global::Packet(ta.bytes); // int totalModels = pkt.ReadInt(); // for (int i = 0; i < totalModels; i++) // { // string name = pkt.readLongString(); // int materialCount = pkt.ReadInt(); // string[] materials = new string[materialCount]; // for (int j = 0; j < materialCount; j++) // { // materials[j] = pkt.readLongString(); // } // float x = pkt.readFloat2(); // float y = pkt.readFloat2(); // float z = pkt.readFloat2(); // float heightFromTerrain = pkt.readFloat2(); // float rx = pkt.readFloat2(); // float ry = pkt.readFloat2(); // float rz = pkt.readFloat2(); // float rw = pkt.readFloat2(); // float sx = pkt.readFloat2(); // float sy = pkt.readFloat2(); // float sz = pkt.readFloat2(); // int mask = pkt.ReadInt(); // //Debug.Log(name); // //GameObject resource = Resources.Load("AssetPacks/PolygonFantasyKingdom/Models/" + name) as GameObject; // GameObject resource = OnDemandLoader.Load("AssetPacks/PolygonFantasyKingdom/Models/" + name); // if (resource != null) // { // //Debug.LogError("World" + 3); // GameObject g = GameObject.Instantiate(resource) as GameObject; // g.AddComponent(); // //MeshRenderer meshRenderer = g.AddComponent(); // //MeshFilter meshFilter = g.AddComponent(); // //meshFilter.sharedMesh = Resources.Load("AssetPacks/PolygonFantasyKingdom/Models/" + name) as Mesh; // // g.name = name; // if (g.GetComponent() == null) // { // g.AddComponent(); // } // //Material m = Resources.Load("AssetPacks/PolygonFantasyKingdom/Materials/" + materials[0]) as Material; // Material m = OnDemandLoader.Load("AssetPacks/PolygonFantasyKingdom/Materials/" + materials[0]); // g.GetComponent().material = m; // //g.GetComponent().materials = new Material[materialCount]; // for (int j = 0; j < g.GetComponent().materials.Length; j++) // { // // if (j < materials.Length) // { // //g.GetComponent().materials[j] = Resources.Load("AssetPacks/PolygonFantasyKingdom/Materials/" + materials[j]) as Material; // g.GetComponent().materials[j] = OnDemandLoader.Load("AssetPacks/PolygonFantasyKingdom/Materials/" + materials[j]); // } // } // // // g.transform.position = new Vector3(x, y, z); // g.transform.rotation = new Quaternion(rx, ry, rz, rw); // g.transform.localScale = new Vector3(sx, sy, sz); // g.transform.parent = transform; // // //ObjectType t = g.AddComponent(); // //t.setmask(mask); // // //if (!t.isGround && !t.isGroundDetail) // //{ // // MeshCollider col = g.AddComponent(); // //} // // Transform[] children = g.GetComponentsInChildren(); // for (int j = 0; j < children.Length; j++) // { // // if (children[j].GetComponent() != null) // { // // children[j].gameObject.GetComponent().material = m; // children[j].gameObject.AddComponent(); // } // } // } // } // } }