- Home /
Is there a way to trigger OnBecameVisible when invisible
I have a mesh that I want to trigger OnBecameVisible when it would normally be supposed to be rendered in the camera, however, I dont actually want to see it in the scene. One thought I had was to attach a transparent material to it but Im worried that the alpha calculations might be a performance hit. Are there any other ways to achieve this?
The use is to check if a $$anonymous$$esh based grid is visible and if it is to load the contents in that grid space. Its much more efficient to use then checking every grid space against the camera every frame. So no, calling it directly wouldn't work in this situation. Im trying to take advantage of the internal events being called ins$$anonymous$$d of invoking extra calculations every frame.
Answer by Eric5h5 · Mar 22, 2014 at 12:46 AM
You can make a mesh composed only of vertices that define the bounding box of the mesh, with no triangles. It will be invisible but will still be "rendered", such as it is, so it works with OnBecameVisible/Invisible.
That is a very creative work around, so is OnBecameVisible triggered if the bounding box is in the camera view? Is there a way to programmatically force the bounding box to be bigger then it really is? Im looking at the documentation trying to figure out if $$anonymous$$esh.bounds has a setter, it doesnt really say much on that end.
You can just set the vertices to make the box be whatever size you want.