示例#1
0
    // 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));
    }
示例#2
0
    // 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));
    }
示例#3
0
文件: lmUtil.cs 项目: sfszh/littleMap
 // Use this for initialization
 void Start()
 {
     primitiveMap = GameObject.Find("map");
     map          = (lmMap)primitiveMap.GetComponent(typeof(lmMap));
 }
示例#4
0
文件: lmUtil.cs 项目: sfszh/littleMap
 // Use this for initialization
 void Start()
 {
     primitiveMap = GameObject.Find("map");
     map = (lmMap)primitiveMap.GetComponent(typeof(lmMap));
 }