- Home /
Return an array of meshes displayed on screen
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?
Answer by happyalex198 · Aug 16, 2011 at 12:10 AM
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.
Answer by dmtsui · Aug 16, 2011 at 12:20 AM
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.
Please don't answer an answer with an answer. use the 'comment' button
Answer by DaveA · Aug 16, 2011 at 12:26 AM
You could find all objects with Renderers and check their isVisible flag http://unity3d.com/support/documentation/ScriptReference/Renderer-isVisible.html
Your answer
Follow this Question
Related Questions
Meshes were scrambled 0 Answers
Switching between 3 cameras doesn't work 1 Answer
How to make camera position relative to a specific target. 1 Answer
Texture 2D Arrays in Parallax Occlusion Mapping 0 Answers
Make an array of all visible objects 1 Answer