MonoBehaviour.OnDrawGizmosSelected 当选择时绘制Gizmos

function OnDrawGizmosSelected () : void


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


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.


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