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);
}
最后修改:2011年1月2日 Sunday 17:53

本脚本参考基于Unity 3.4.1f5

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