Renderer.enabled 启用

var enabled : bool

Description描述

Makes the rendered 3D object visible if enabled.

如果启用,使被渲染的物体可见。这是一个物体隐藏显示的开关。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public void Awake() {
		renderer.enabled = false;
	}
}
// make the object invisible
//使物体不显示
renderer.enabled = false;

另一个例子:

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void Update() {
		int seconds = Time.time;
		bool oddeven = seconds % 2 == 0;
		renderer.enabled = oddeven;
	}
	public void Awake() {
		renderer.enabled = true;
	}
}
// Toggle the Object's visibility each second.
// make the object visible
//每秒切换物体的可见性
//使物体可见
renderer.enabled = true;

function Update () {
	// Find out whether current second is odd or even
	//找出当前秒是奇数还偶数
	var seconds : int = Time.time;
	var oddeven = (seconds % 2) == 0;
	// Enable renderer accordingly
	//启用相应的渲染
	renderer.enabled = oddeven;
}
Page last updated: 2010-12-16