Hi all, I have this very simple script in which I try to iterate through every MeshFilter that contains my root GameObject. Code (csharp): #pragma strict import System.Collections.Generic; @script RequireComponent(MeshFilter) @script RequireComponent(MeshRenderer) function Start () { var meshFilters = GetComponentsInChildren.<MeshFilter>(); var length:uint = meshFilters.Length; for (var i:uint = 0; i < length; i++){ if (meshFilters[i].mesh) Debug.Log("mesh : " + meshFilters[i].mesh); } } My scene is about more 500 meshes for about 272.5 triangles. When I launch the scene I have a window error which displays the following message: After few tests I can say that the line of code wich make the editor crash is Code (csharp): meshFilters[i].mesh Actually is trying to access this property of too many objects that make the editor crash. So there is a solution to allow iterate all that meshFilter objects and be able to access to any property of them without having the editor crash ? Any idea ? Thank you guys.
Hi, So nobody has any idea ? Does that mean it's not possible to iterate through all meshes of a scenes which contains (to) many meshes and/or triangles ? Thank you.
Try sharedMesh instead of mesh. Accessing mesh forces Unity to create a copy of the mesh specific to that object, which consumes memory; so your loop is actually creating 500 copies of your mesh.