Unity自定义Gizmos (Making Custom Gizmos

首先,准备一张带Alpha通道的图片,如下图所示:

然后,在Unity project下创建一个Gizmos的文件夹,导入自定义的图片

最后,创建脚步文件,以C#语言为例:

public class example : MonoBehaviour {
    void OnDrawGizmos() {
        Gizmos.DrawIcon(transform.position, "文件名(带后缀");
    }
}

并将脚步附加到game object。


附:

如果你不想通过编写代码的方式自定义gizmo,还可以在game object的Inspector面板通过点击左上角的带箭头的图标,然后,点击“Other”,选择图片。

Unity自定义Gizmos (Making Custom Gizmos_第1张图片

你可能感兴趣的:(Unity自定义Gizmos (Making Custom Gizmos)