I’d like to have a boolean public property on a gameobject named ‘isVisible’.
The property would automatically set to true or false depending if it was in the main camera’s viewport.
Any ideas.
I’d like to have a boolean public property on a gameobject named ‘isVisible’.
The property would automatically set to true or false depending if it was in the main camera’s viewport.
Any ideas.
This is more a function of a renderer, and in fact Renderer sends the message OnBecameVisible and OnBecameInvisible.
Try this:
var isVisible = false;
function OnBecameVisible() {
isVisible = true ;
}
function OnBecameInvisible() {
isVisible = false ;
}
Edit: Woops! Didn’t notice Starmanta already had answered…