DrawGizmo.DrawGizmo 构造DrawGizmo

static function DrawGizmo (gizmo : GizmoType) : DrawGizmo

Description描述

Defines when the gizmo should be invoked for drawing.

当gizmo应该绘制调用时定义。

参见:GizmoType

/// The RenderLightGizmo function will be called if the light is not selected.
/// The gizmo is drawn when picking.
///如果灯光不选择RenderLightGizmo函数将被调用
///当点选时gizmo被绘制

@DrawGizmo (GizmoType.NotSelected | GizmoType.Pickable)
static function RenderLightGizmo (light : Light, gizmoType : GizmoType) {
	var position = light.transform.position;
	// Draw the light icon //绘制灯光图标
	// (A bit above the one drawn by the builtin light gizmo renderer)
	Gizmos.DrawIcon (position + Vector3.up, "Light Gizmo.tiff");

	// Are we selected? Draw a solid sphere surrounding the light
	//当选择时,围绕灯光绘制一个球形
	if ((gizmoType & GizmoType.SelectedOrChild) != 0) {
		// Indicate that this is the active object by using a brighter color.
		//使用明亮的颜色,表明这是激活的物体
		if ((gizmoType & GizmoType.Active) != 0)
			Gizmos.color = Color.red;
		else
			Gizmos.color = Color.red * 0.5;
		Gizmos.DrawSphere (position, light.range);
	}
}

/*
// Draw the gizmo if it is selected or a child of the selection.
// This is the most common way to render a gizmo
//如果它或它的子物体被选择,绘制gizmo;这是最常用的渲染gizmo方法

@DrawGizmo (GizmoType.SelectedOrChild)

// Draw the gizmo only if it is the active object.
//仅绘制激活物体的gizmo

@DrawGizmo (GizmoType.Active)]
*/
/// C# example
using UnityEditor;
using UnityEngine;

class GizmoTest {
	/// The RenderLightGizmo function will be called if the light is not selected.
	/// The gizmo is drawn when picking.
	[DrawGizmo (GizmoType.NotSelected | GizmoType.Pickable)]
	static void RenderLightGizmo (Light light, GizmoType gizmoType) {
		Vector3 position = light.transform.position;
		// Draw the light icon
		// (A bit above the one drawn by the builtin light gizmo renderer)
		Gizmos.DrawIcon (position + Vector3.up, "Light Gizmo.tiff");

		// Are we selected? Draw a solid sphere surrounding the light
		if ((gizmoType & GizmoType.SelectedOrChild) != 0) {
			// Indicate that this is the active object by using a brighter color.
			if ((gizmoType & GizmoType.Active) != 0)
				Gizmos.color = Color.red;
			else
				Gizmos.color = Color.red * 0.5F;
			Gizmos.DrawSphere (position, light.range);
		}
	}
}
/*
// Draw the gizmo if it is selected or a child of the selection.
// This is the most common way to render a gizmo
[DrawGizmo (GizmoType.SelectedOrChild)]

// Draw the gizmo only if it is the active object.
[DrawGizmo (GizmoType.Active)]
*/

• static function DrawGizmo (gizmo : GizmoType, drawnGizmoType : Type) : DrawGizmo

Description描述

Same as above. drawnGizmoType determines of what type the object we are drawing the gizmo of has to be.

同上。drawnGizmoType确定了要绘制gizmo物体是什么类型。

If drawnGizmoType is null, the type will be determined from the first parameter of the draw gizmo method.

如果drawnGizmoType类型为null,该类型将从绘制gizmo方法的首个参数来确定。

最后修改:2011年5月27日 Friday 17:36

本脚本参考基于Unity 3.4.1f5

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