コード例 #1
0
    private Mesh CreateTile(Vector3 index0, Vector3 index1, Vector3 index2, Vector3 index3)
    {
        MeshGen mesh = new MeshGen();

        // Mesh Generation
        mesh.Vertices.Add(index0);
        mesh.UV.Add(new Vector2(0f, 0f));
        mesh.Normals.Add(Vector3.up);

        mesh.Vertices.Add(index1);
        mesh.UV.Add(new Vector2(0f, 1f));
        mesh.Normals.Add(Vector3.up);

        mesh.Vertices.Add(index2);
        mesh.UV.Add(new Vector2(1f, 1f));
        mesh.Normals.Add(Vector3.up);

        mesh.Vertices.Add(index3);
        mesh.UV.Add(new Vector2(1f, 0f));
        mesh.Normals.Add(Vector3.up);

        mesh.CreateTriangles(new Vector3Int(0, 1, 2));
        mesh.CreateTriangles(new Vector3Int(0, 2, 3));

        mesh.ApplyMeshChanges();

        return(mesh.Mesh);
    }