105 lines
3.6 KiB
C#
105 lines
3.6 KiB
C#
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<GameObject>("AssetPacks/PolygonFantasyKingdom/Models/" + name);
|
|
// if (resource != null)
|
|
// {
|
|
// //Debug.LogError("World" + 3);
|
|
// GameObject g = GameObject.Instantiate(resource) as GameObject;
|
|
// g.AddComponent<MeshCollider>();
|
|
// //MeshRenderer meshRenderer = g.AddComponent<MeshRenderer>();
|
|
// //MeshFilter meshFilter = g.AddComponent<MeshFilter>();
|
|
// //meshFilter.sharedMesh = Resources.Load("AssetPacks/PolygonFantasyKingdom/Models/" + name) as Mesh;
|
|
//
|
|
// g.name = name;
|
|
// if (g.GetComponent<MeshRenderer>() == null)
|
|
// {
|
|
// g.AddComponent<MeshRenderer>();
|
|
// }
|
|
// //Material m = Resources.Load("AssetPacks/PolygonFantasyKingdom/Materials/" + materials[0]) as Material;
|
|
// Material m = OnDemandLoader.Load<Material>("AssetPacks/PolygonFantasyKingdom/Materials/" + materials[0]);
|
|
// g.GetComponent<MeshRenderer>().material = m;
|
|
// //g.GetComponent<MeshRenderer>().materials = new Material[materialCount];
|
|
// for (int j = 0; j < g.GetComponent<MeshRenderer>().materials.Length; j++)
|
|
// {
|
|
//
|
|
// if (j < materials.Length)
|
|
// {
|
|
// //g.GetComponent<MeshRenderer>().materials[j] = Resources.Load("AssetPacks/PolygonFantasyKingdom/Materials/" + materials[j]) as Material;
|
|
// g.GetComponent<MeshRenderer>().materials[j] = OnDemandLoader.Load<Material>("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<ObjectType>();
|
|
// //t.setmask(mask);
|
|
//
|
|
// //if (!t.isGround && !t.isGroundDetail)
|
|
// //{
|
|
// // MeshCollider col = g.AddComponent<MeshCollider>();
|
|
// //}
|
|
//
|
|
// Transform[] children = g.GetComponentsInChildren<Transform>();
|
|
// for (int j = 0; j < children.Length; j++)
|
|
// {
|
|
//
|
|
// if (children[j].GetComponent<Renderer>() != null)
|
|
// {
|
|
//
|
|
// children[j].gameObject.GetComponent<Renderer>().material = m;
|
|
// children[j].gameObject.AddComponent<MeshCollider>();
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
}
|