Please tell me why renderer.isVisible and void OnBecameVisible() always true? I checked both in Unity Editor and in Build - always true, although Occlusion disables these portal planes.
I need to somehow disable/enable OnPostRender() on cameras which retranslates the views to the portal planes, if the portal planes are not visible in Occlusion.
But I can’t do this and Unity consumes a lot of resources, constantly displaying the image of all cameras on all portal planes.
Of course, I can use raycast from the Z axis of the character into the portals - but this is wrong way.
How can I understand that Occlusion has disabled / enabled the Mesh Renderer of Portal Planes?
And why renderer.isVisible and void OnBecameVisible() always true?
As far as I remember, the scene view camera counts as a camera, so if the scene view is seeing the objects, then they are considered isVisible will be true.
Maybe try closing the scene view and looking only at the game view to see if it works.
I also had such thought and it looks like the truth, but then how can I disable the OnPostRender() of cameras if Occlusion does not see the portal planes?
To use raycast from the character into all portals in Update()? But this is not normal!
The most interesting thing is that I only need a flag - whether the object was hidden by Occlusion or not - and it turns out to be so difficult! It looks like some kind of cheat. Why then does the isVisible flag exist if the object is hidden on the scene, but it is shown somewhere inside?
This is a very strange situation. Even if I turn off the cameras, Mesh Renderer.isVisible shows true. But still, sometimes, because of solar flares, isVisible = false appears, but extremely rarely and according to incomprehensible rules.
I read this post:
how to specify object for Renderer.isVisible?
… I did absolutely the same - it does not help.
It does not work in either the Unity Editor or the Build Version. Even if the cameras are turned off on the scene, OnPostRender() still works in them. A paradox!
I suspect that the cameras (not MainCamera) see these portals, pointing to the places of resurrection - so renderer.isVisible is always true, even if MainCamera does not see them and they are hidden by the Occlusion system.
This example helped me! I used: ```csharp
**Plane planes = GeometryUtility.CalculateFrustumPlanes(Camera.main);
if (GeometryUtility.TestPlanesAABB(planes, _objectRender.bounds)) {
Debug.LogWarning(“Object inside frustum!”);
} else {
Debug.LogWarning(“Object not visible!”);
}** ``` But I don’t know how much this solution will eat up resources in fps…
The solution works and has increased the fps to 7-12 units.
I do not recommend contacting renderer.isVisible and void OnBecameVisible() at all.
According to the forums and comments and from my experience - there is some kind of mess going on.