- Home /
Custom 2D Rectangle Resizing Handles
Unity has some useful controls for resizing sprites in 2D mode, the blue corners in the image below:
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?
Answer by noio · Jul 21, 2014 at 05:23 PM
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.
Answer by EvDave · Sep 12, 2015 at 02:05 AM
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.
Your answer
![](https://koobas.hobune.stream/wayback/20220613154542im_/https://answers.unity.com/themes/thub/images/avi.jpg)