示例#1
0
    void SendMesh()
    {
        MeshFilter[] meshFilters = GetComponentsInChildren <MeshFilter>();
        //Debug.Log("SendMesh " + meshFilters.Length);
        CombineInstance[] combine = new CombineInstance[meshFilters.Length];
        int i = 0;

        while (i < meshFilters.Length)
        {
            combine[i].mesh      = meshFilters[i].sharedMesh;
            combine[i].transform = meshFilters[i].transform.localToWorldMatrix;
            //meshFilters[i].gameObject.SetActive( false );
            i++;
        }

        Mesh combinedMesh = new Mesh();

        combinedMesh.CombineMeshes(combine, true, true);
        combinedMesh.RecalculateBounds();
        combinedMesh.RecalculateNormals();

        /*
         * Color32[] colors = new Color32[combinedMesh.vertexCount];
         * for(  i = 0; i < combinedMesh.vertexCount; i++)
         * {
         *  colors[i] = new Color32(255, 255, 255, 255);
         * }
         * combinedMesh.colors32 = colors;
         *
         */

        _sender.SetMesh(combinedMesh);
    }
示例#2
0
 void Update()
 {
     _sender.SetMesh(_filter.mesh);
 }