LoginSignup
0
0

More than 1 year has passed since last update.

Unity count mesh

Posted at
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class CountMesh : MonoBehaviour {

	[MenuItem("Tools/MESHS")]
    static void LogMeshF()
    {
        List<MeshFilter> mesh = new List<MeshFilter>();
        GameObject[] gameObjects = Selection.gameObjects;
        for (int i = 0; i < gameObjects.Length; i++)
        {
            MeshFilter[] meshFilters= gameObjects[i].GetComponentsInChildren<MeshFilter>();
            for (int j = 0; j < meshFilters.Length; j++)
            {
                if (!mesh.Contains( meshFilters[j]))
                {
                    mesh.Add(meshFilters[j]);
                } 
            }
        }

        int virtices=0;
        int tris=0;
        for (int i = 0; i < mesh.Count; i++)
        {
            virtices += mesh[i].sharedMesh.vertexCount;
            tris += mesh[i].sharedMesh.triangles.Length/3;

        }
        Debug.Log("virtices:"+ virtices + " tris:"+tris);
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0