如果您想绘制能够选择并且始终绘制的辅助图标,则可以实现 OnDrawGizmos。
This allows you to quickly pick important objects in your Scene.
注意,OnDrawGizmos 将使用相对于场景视图的鼠标位置。
This function does not get called if the component is collapsed in the Inspector. Use OnDrawGizmosSelected to draw gizmos when the game object is selected.
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { void OnDrawGizmos() { // Draw a yellow sphere at the transform's position Gizmos.color = Color.yellow; Gizmos.DrawSphere(transform.position, 1); } }
另请参阅:OnDrawGizmosSelected。