Camera.OnWillRenderObject Manual     Reference     Scripting  
Scripting > Runtime Classes > Camera
Camera.OnWillRenderObject

function OnWillRenderObject () : void

Description

OnWillRenderObject is called once for each camera if the object is visible.

The function is called during the culling process just before rendering all culled objects. You might use this to create dependent render textures and you want to update the render texture only if the rendered object will actually be visible. As an example this is used by the water component.

Camera.current will be set to the camera that will render the object.

JavaScripts
// Increases the size of otherObject while this transform is being rendered.
// Be aware that this will be called even if the Scene Editor displays the object
// So make sure to not see the object either in the game view nor the scene editor.

var otherObject : GameObject;

function OnWillRenderObject() {
otherObject.transform.localScale *= 1.0001;
}

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
public GameObject otherObject;
void OnWillRenderObject() {
otherObject.transform.localScale *= 1.0001F;
}
}

import UnityEngine
import System.Collections

class example(MonoBehaviour):

public otherObject as GameObject

def OnWillRenderObject():
otherObject.transform.localScale *= 1.0001F