Renderer.OnBecameInvisible 变得不可见

function OnBecameInvisible () : void

Description描述

OnBecameInvisible is called when the object is no longer visible by any camera.

当物体任意摄像机变不再可见时,OnBecameInvisible被调用

This message is sent to all scripts attached to the renderer. OnBecameVisible and OnBecameInvisible are useful to avoid computations that are only necessary when the object is visible.

这个消息发送到附加到该渲染器的所有脚本。OnBecameVisibleOnBecameInvisible对避免计算非常有用的,只需要当物体可见时计算。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void OnBecameInvisible() {
		enabled = false;
	}
}
// Disables the behaviour when it is invisible
//当物体不可见时,禁用这个行为
function OnBecameInvisible () {
	enabled = false;
}

Note: when running in the editor, scene view cameras will also cause this function to be called.

注意:当运行在编辑器,场景视图摄像机也将导致这个函数被调用。

参见: OnBecameVisible, isVisible.

最后修改:2010年12月17日 Friday 22:14

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。