Handles to manipulate Sprite/Texture`s size during runtime.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By shreyk27

How do i enable or go about writing a custom function that enables to manipulate the size of a sprite/texture during runtime using handles that are available in the editor, like in a ui/ux desiging application?

In short you’ll need to add some gui (Control) nodes, e.g. a SpinBox, and you can connect its value_changed signal to a script that resizes the sprite/texture based on the value
or if you don’t like SpinBox, you can take a look at what nodes inherit Range, e.g. HSlider

1234ab | 2021-04-16 13:01

OP specifically asked for handles like in the editor, not a SpinBox.

exuin | 2021-04-16 16:15

ohh yeah I misunderstood handles, I thought they meant something like a HSlider (I always use the inspector to set sizes :D, they are more precise, that’s why I thought about that spinbox-hslider combo the inspector has)

1234ab | 2021-04-16 16:25

:bust_in_silhouette: Reply From: exuin

The Godot editor is actually a Godot project, but you won’t be able to use the handles from the editor directly. You’ll need to make your own handles.

One way to do this is to make a panel, set it to the size of the texture, and then give a StyleBoxFlat with the center not shown. Anchor a bunch of TextureButtons to the sides and corners of the panel. Detect clicks on the buttons and change the size of the panel to be where the mouse has moved. Also change the size of the texture as well.

an idea:
it can be fancy and user friendly (if you use the default cursor) if you set the TextureButtons’ mouse_default_cursor_shape to match the direction you can resize it

1234ab | 2021-04-16 16:42