- Home /
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?
Answer by HappyMoo · Jan 02, 2014 at 05:03 PM
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
Any idea how to do something like this and have it run in Scene view? I've got @script ExecuteInEdit$$anonymous$$ode() at the head of my script but no dice so far.
Use:
print(gameObject.name + ' is being rendered by ' + Camera.current.name + ' at ' + Time.time);
i.e. gameOject to gameObject.
Your answer
![](https://koobas.hobune.stream/wayback/20220613125339im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How can i make an automatic world generator? 1 Answer
Get all Render Objects in our current Scene with code (js) 1 Answer
How can i make my game lag less? 1 Answer
Faking reflection with changing render order? 0 Answers
Render toggle help.. 1 Answer