Using OnWillRenderObject

My code is like this:

var thing : Transform;

function Update(){
	Camera.OnWillRenderObject(thing){
		print("it works");
	}
}

but it says that I need to insert a semicolon at the end of OnWillRenderObject. I clearly can’t use OnWillRenderObject like I should. Can somebody give an example how to use it properly?

No, you don’t call it on the cam… the cam calls it on your Behaviour if the gameObject will be rendered by that cam in that frame…

function OnWillRenderObject()
{
  print(gameOject.name + ' is being rendered by ' + Camera.current.name + ' at ' + Time.time);
}

Now drag that on some object and start your game and try what happens if you look at it or if you look away

Use:

print(gameObject.name + ' is being rendered by ' + Camera.current.name + ' at ' + Time.time);

i.e. gameOject to gameObject.