Custom 2D Rectangle Resizing Handles

Unity has some useful controls for resizing sprites in 2D mode, the blue corners in the image below:

[29446-screen+shot+2014-07-20+at+17.42.55.png|29446]

I’m adding some triggers and invisible objects to my game, and I’m wondering what the best way is to mimic those kind of 2D area resizing controls for objects without a SpriteRenderer. Is there any way to get Unity to draw those blue handles for my custom object?

More general: is there a way to create conveniently editable rectangular placeholder objects?

I put something like this together using the SpriteRenderer for its handles. I simply added a disabled SpriteRenderer to the placeholder region GameObject, even though it’s disabled, the blue handles still show. Then I used Gizmo.DrawCube to fill the rectangular region like so:

Gizmos.DrawCube(transform.localPosition + transform.localScale / 2, 
                transform.localScale);

I do think that the SpriteRenderer needs to have its Sprite property set, because the pivot determines the positioning of the handles.

[29505-screen+shot+2014-07-21+at+18.32.21.png|29505]

Hi, unity has a component that can be used as a general-purpose editable rectangle.
It can be found under Add Component → Layout → Rect Transform.