0 votes

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?

Godot version 3.2
in Engine by (44 points)

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

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

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)

1 Answer

+1 vote

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.

by (8,546 points)

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.