- Home /
Deactivating the hiding of objects that are out of camera view
GameObjects that are out of the camera view hide by default. I have an object with a shader and the shader makes the object look bigger then it actually is. That leads to hiding the object, while its actually still visible.
Is there a way to disable that hiding of objects or increase the distance or something?
Answer by Bunny83 · Mar 14, 2020 at 04:49 AM
Yes there is. Unity uses the AABB of the mesh to determine if it's in the viewing frustum or not. You would need to set your own Bounds for your mesh. To just double the original AABB size you can just do
Bounds bounds = yourMesh.bounds;
bounds.extents *= 2f;
yourMesh.bounds = bounds;
Though if you know the possible range that your shader might manipulate the vertices you could be more thoughtful about how you setup your bounds.
I tried that but it didn't work. i used:
foreach (GameObject crystal in GameObject.FindGameObjectsWithTag("Crystal"))
{
Bounds bounds = crystal.GetComponent<$$anonymous$$eshFilter>().mesh.bounds;
bounds.extents *= 2f;
crystal.GetComponent<$$anonymous$$eshFilter>().mesh.bounds = bounds;
}
but it still hides them to early.