// Use this for initialization void Start() { Debug.Log("Hello"); MeshFilter meshFilter = (MeshFilter)gameObject.GetComponent(typeof(MeshFilter)); Mesh mesh = meshFilter.sharedMesh; if (!mesh) { Debug.LogWarning("mesh is not exist"); } lmMap map = (lmMap)gameObject.GetComponent(typeof(lmMap)); map.OnEnable(); map.GetVertices(); map.GetTriangles(); map.GetSpecialTiles(gameObject); map.GetUVs(); mesh.vertices = map.mapVertices.ToArray(); mesh.triangles = map.mapTriangles.ToArray(); mesh.uv = map.mapUVs.ToArray(); mesh.RecalculateNormals(); mesh.RecalculateBounds(); mesh.Optimize(); gameObject.AddComponent(typeof(MeshCollider)); }
// Use this for initialization void Start() { MeshFilter meshFilter = (MeshFilter)gameObject.GetComponent(typeof(MeshFilter)); MeshRenderer meshRenderer = (MeshRenderer)gameObject.GetComponent(typeof(MeshRenderer)); Material mat = Resources.Load("Cliff/Materials/a2", typeof(Material)) as Material; if (mat != null) { meshRenderer.material = mat; } else { Debug.Log("MapLoader: fail to load mat"); } //MeshFilter meshFilter = (MeshFilter)gameObject.GetComponent(typeof(MeshFilter)); Mesh mesh = meshFilter.mesh; lmMap map = (lmMap)gameObject.GetComponent(typeof(lmMap)); //fixme vertices triangles uv return immediate map.GetVertices(); map.GetTriangles(); map.GetSpecialTiles(gameObject); map.GetUVs(); mesh.vertices = map.mapVertices.ToArray(); mesh.triangles = map.mapTriangles.ToArray(); mesh.uv = map.mapUVs.ToArray(); mesh.RecalculateNormals(); mesh.RecalculateBounds(); mesh.Optimize(); gameObject.AddComponent(typeof(MeshCollider)); }