- Home /
Renderer.isVisible = FALSE on app start, TRUE on following frames?
Render.isVisible seems to behave unreliably on app start. Is this expected? Example:
1) Create empty scene
2) Paste this on GameObject that is in camera view, and Run:
public class RendererIsVisibleTest : MonoBehaviour
{
private Renderer rend;
// Use this for initialization
void Start ()
{
rend = GetComponent<Renderer>();
Debug.Log(rend.isVisible);
}
// Update is called once per frame
void Update ()
{
Debug.Log(rend.isVisible);
}
}
Result:
False
False
False
True (always True from now on)
So we can see that on Start the result traces False, although the object with the renderer is in view on start (both in game camera view and Editor view). Also next couple of frames trace False, before we get consistent True traces. In another project i have, Start traces False, but first Update cycle already traces True - very inconsistent.
Is this expected behavior? Bug? I could wait some time and start tracing then (im expecting True as first trace result), but is this preferred implementation? How long to wait, since sometimes it takes 3 frames to get proper value, sometimes just 1 frame?
This delayed execution seems like a bad implementation, and Unity's behavior seems like a bug to me. Please post your suggestions / ideas. I need to get TRUE as first trace and id (preferably) like to use Renderer.isVisible as it fits in my current system.