Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Handles.DrawSolidRectangleWithOutline

static function DrawSolidRectangleWithOutline(verts: Vector3[], faceColor: Color, outlineColor: Color): void;
static void DrawSolidRectangleWithOutline(Vector3[] verts, Color faceColor, Color outlineColor);
static def DrawSolidRectangleWithOutline(verts as Vector3[], faceColor as Color, outlineColor as Color) as void

Parameters

vertsThe 4 vertices of the rectangle in world coordinates.

Description

Draw a solid outlined rectangle in 3D space.


Solid rectangle with a black outline in the Scene View.

	// Create a semi transparent rectangle that lets you modify 
	// the "range" var that resides in "SolidRectangleExample.js"
	
	@CustomEditor (SolidRectangleExample)
	class DrawSolidRectangle extends Editor {
	    function OnSceneGUI () {
	    	var pos : Vector3 = target.transform.position;
	 
			var verts : Vector3[] = [Vector3(pos.x - target.range,pos.y,pos.z-target.range), 
						Vector3(pos.x-target.range,pos.y,pos.z + target.range), 
						Vector3(pos.x+target.range,pos.y,pos.z + target.range), 
						Vector3(pos.x+target.range,pos.y,pos.z-target.range)];
	        Handles.DrawSolidRectangleWithOutline(verts, Color(1,1,1,0.2), Color(0,0,0,1));
	        
	        for(var posCube : Vector3 in verts)
	        	target.range = Handles.ScaleValueHandle(target.range,
        							posCube,
        							Quaternion.identity,
        							1,
        							Handles.CubeCap,
        							1);
	    }
	}

And the script attached to this Handle:

	//SolidRectangleExample.js
	
	var range : float = 5;