Is there a way to return an array of gameobjects or meshes displayed on screen using camera or occlusionArea? I don’t want everything, just what is actually being rendered on screen. Initially, I thought if I used OcclusionArea.FindObjectOfType or Camera.FindObjectOfType that it would return an array of gameobjects that are displayed on screen, but it just returned all the gameobjects I had loaded in the scene. The reason for this is when I generate mesh colliders from my FBX files I end up hitting a limit to the amount of colliders I can have in the scene. So what I want to do is be able to generate colliders on the fly based on the meshes that are displayed on screen and destroy them when I’m done. Any thoughts?
I think the problem might be that you are trying to use very complicated meshes for your colliders. Instead of using the full detail mesh from the FBX file, have you considered creating a very low polygon mesh to use as a collider. You could also create a “compound collider” out of primitives as discussed here http://unity3d.com/support/documentation/Components/class-BoxCollider.html. Using simple geometry for detecting collisions will probably also speed up performance significantly.
Indeed, the meshes are very complex, but I have no control over that aspect. I need the colliders to match up because I’m using it for extreme precision. It would be much easier if this were for a game, I would optimize the actual geometry, but this is for an application I’m trying to develop and the only way around the limitations of the engine that I can think of is to generate a small portion of the mesh colliders when I need them and dispose of them afterwards. I’m not sure if that is even possible.
You could find all objects with Renderers and check their isVisible flag http://unity3d.com/support/documentation/ScriptReference/Renderer-isVisible.html