unity 网格Mesh占用内存公式

来源:互联网 发布:上海联创汽车电子知乎 编辑:程序博客网 时间:2024/06/02 07:27
Unity版本:5.1.2
 
网格顶点数量 / 7.845  =  网格占用内存 


    [MenuItem("Assets/GetVerctorNum")]    static void GetVerctorNum() {        Object[] selectedAsset = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);        int count = 0;        int meshCount = 0;        int triCount = 0;        for (int i = 0; i < selectedAsset.Length; i++) {            GameObject obj = selectedAsset[i] as GameObject;                      MeshFilter[] filters = obj.GetComponentsInChildren<MeshFilter>(true);            if(filters != null){                for (int j = 0; j < filters.Length; j++) {                    MeshFilter f = filters[j];                    count += f.sharedMesh.vertexCount;                    triCount += f.sharedMesh.triangles.Length / 3;                    meshCount++;                }            }        }        Debug.LogWarning("总共Mesh=" + meshCount + "   总共顶点=" + count  + "   总共三角形="+triCount);    }


0 0
原创粉丝点击