MonoBehaviour.OnWillRenderObject 当渲染物体之前

function OnWillRenderObject () : void

Description描述

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

如果对象可见每个相机都会调用它。

The function is not called if the MonoBehaviour is disabled.

如果MonoBehaviour被禁用,此函数将不被调用。

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.

Camera.current将被设置为要渲染这个物体的相机。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public GameObject otherObject;
	void OnWillRenderObject() {
		otherObject.transform.localScale *= 1.0001F;
	}
}
// 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.
// When on Play mode.
// 当此transform被渲染时增大物体大小. 在运行模式下,注意在场景编辑器显示物体时,game面板和场景编辑器任何一个没有看到物体时,此函数是否被调用,
var otherObject : GameObject ;

function OnWillRenderObject() {
	otherObject.transform.localScale *= 1.0001;
}
Page last updated: 2011-1-2