- Home /
Help with drawing a cube in a custom editor
I'm trying to draw a cube in a custom editor script. I've done as much research as I possibly can but have not found a solution. The scripting reference is absolutely useless in my case. I'm trying to use the DrawGizmo attribute to then be able to draw a cube into the scene view. I do not get any errors, I get nothing at all. This is my script so far. From the vague documentation I've read, this should work. Unless I'm completely missing something here? Any help would be appreciated.
using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomEditor (typeof (EnemyZone) )]
public class AIZoneEditor : Editor {
[DrawGizmo (GizmoType.NotSelected)]
static void DrawZone ()
{
Gizmos.DrawCube (Vector3.zero, new Vector3 (2,2,2) );
}
}
Comment
Gizmos are drawn in the methods OnDrawGizmos() and OnDrawGizmosSelected(). The script needs to be attached to the GameObject, and the inspector must not be collapsed.
Are you trying to use this in an editor script? And what is line 9 supposed to do?
Your answer