MonoBehaviour.OnDrawGizmosSelected 当选择时绘制Gizmos

function OnDrawGizmosSelected () : void

Description描述

Implement this OnDrawGizmosSelected if you want to draw gizmos only if the object is selected.

如果你想在物体被选中时绘制gizmos,执行这个函数。

Gizmos are drawn only when the object is selected. Gizmos are not pickable. This is used to ease setup. For example an explosion script could draw a sphere showing the explosion radius.

Gizmos只在物体被选择的时候绘制。Gizmos不能被点选,这可以使设置更容易。例如:一个爆炸脚本可以绘制一个球来显示爆炸半径

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public float explosionRadius = 5.0F;
	void OnDrawGizmosSelected() {
		Gizmos.color = Color.white;
		Gizmos.DrawSphere(transform.position, explosionRadius);
	}
}
var explosionRadius : float = 5.0;

function OnDrawGizmosSelected () {
	// Display the explosion radius when selected
	// 被选中时显示爆炸半径.
	Gizmos.color = Color.white ;
	Gizmos.DrawSphere (transform.position, explosionRadius);
}
Page last updated: 2011-1-2