Esempio n. 1
0
    public void GenternalCube()
    {
        List <Vector3> faces = new List <Vector3> {
            Vector3.right, Vector3.up, Vector3.forward
        };
        List <Vector3> verts   = new List <Vector3> ();
        List <int>     indexes = new List <int> ();

        for (int i = 0; i < 1; i++)
        {
            GizmosTool.AddQuad(verts, indexes, Vector3.forward, faces[0], faces[1]);
            GizmosTool.AddQuad(verts, indexes, Vector3.forward, faces[0], -faces[1]);
        }
        Mesh mesh = new Mesh();

        mesh.name      = "[Cube]";
        mesh.hideFlags = HideFlags.HideAndDontSave;
        mesh.SetVertices(verts);
        mesh.SetIndices(indexes.ToArray(), MeshTopology.Quads, 0);
        mesh.RecalculateNormals();
        mesh.RecalculateBounds();
        mesh.UploadMeshData(true);

        GameObject   temp     = new GameObject("Cube");
        MeshRenderer renderer = temp.AddComponent <MeshRenderer> ();

        renderer.material = new Material(Shader.Find("Standard"));

        MeshFilter meshFilter = temp.AddComponent <MeshFilter> ();

        meshFilter.mesh = mesh;
    }
Esempio n. 2
0
    public void GenternalQuad()
    {
        List <Vector3> verts   = new List <Vector3> ();
        List <int>     indexes = new List <int> ();

        GizmosTool.AddQuad(verts, indexes, Vector3.right, Vector3.up, Vector3.zero);

        Mesh mesh = new Mesh();

        mesh.name      = "[Quad]";
        mesh.hideFlags = HideFlags.HideAndDontSave;
        mesh.SetVertices(verts);
        mesh.SetIndices(indexes.ToArray(), MeshTopology.Quads, 0);
        mesh.RecalculateNormals();
        mesh.RecalculateBounds();
        mesh.UploadMeshData(true);

        GameObject   go       = new GameObject("Quad");
        MeshRenderer renderer = go.AddComponent <MeshRenderer> ();

        renderer.material = new Material(Shader.Find("Standard"));
        MeshFilter meshFilter = go.AddComponent <MeshFilter> ();

        meshFilter.mesh = mesh;
    }