コード例 #1
0
    void Gen()
    {
        int[,,] a = ArrayUtils.Create3D(0, map.width, maxHeight + 1, map.height);
        for (int i = 0; i < map.width; i++)
        {
            for (int j = 0; j < map.height; j++)
            {
                int h = Mathf.FloorToInt(map.GetPixel(i, j).r *maxHeight *.99f);
                for (int k = 0; k < h; k++)
                {
                    a[i, k, j] = 1;
                }
            }
        }
        Mesh       m  = GenerateMeshUtils.ArrayToMesh(a);
        GameObject g  = new GameObject(name);
        MeshFilter mf = g.AddComponent <MeshFilter>();

        mf.mesh = m;
        MeshRenderer mr = g.AddComponent <MeshRenderer>();

        mr.material = material;
        AssetDatabase.CreateAsset(m, path + "" + name + ".asset");
        PrefabUtility.CreatePrefab(path + "" + name + ".prefab", g);
    }
コード例 #2
0
 // Use this for initialization
 void Start()
 {
     GenerateMaze();
     //GenerateMesh();
     mesh = GenerateMeshUtils.ArrayToMesh(maze);
     GetComponent <MeshFilter>().mesh         = mesh;
     GetComponent <MeshCollider>().sharedMesh = mesh;
 }