- Home /
OnBecameInvisible Not Working Real Device
Hello,
I have implemented OnBecameInvisible() and attached the script to my game object. I have added a renderer and got it working, but only when I use the unity editor? The function is never called when I am using a real device such as my android phone. Why is this? Do I need to adjust other settings, such as the camera?
This might sound silly, but is there a renderer on the GameObject that your observing that also has the script on it?
How is it disappearing? It only works when it was visible at some point. In the editor this might work because the object is seen by the editor cam and after play not seen anymore because of maximizeonplay for example.
Yes there is a renderer. I have never used maxonplay for this game, but i have the scene biew over the camera. I have objects that fall from the top of the screen. When they are first created, id say they are half on the screen / half off to show as if they are inco$$anonymous$$g. Is that really an issue? I do have origin prefabs outside of my canvas that are cloned and put in the camera view. They are seen and i can even interact with them with my raycasts.
I can put up some screenshots if needed, let me know.
When I turn on maximize on play, you are right the function is never called. I do use a canvas & only have the main camera.
Answer by gintechsystems · Feb 27, 2015 at 01:34 AM
This may not be the answer for everyone but I have figured out my issue. I changed my canvas render mode to screen space - camera. Apparently that function never gets called when using screen space - overlay, at least to my knowledge I could not figure out how to get it to work. I did also have to resize the camera to the size of the view so that way the camera did see the objects and when they left. I assumed when screen space - overlay was used, the camera would automatically see anything that comes in and leaves. This does not seem to be the case?
Your answer
![](https://koobas.hobune.stream/wayback/20220613184304im_/https://answers.unity.com/themes/thub/images/avi.jpg)