Resizing custom object with 9-patch and text

I haven’t been able to figure out how to resize a custom object with a 9-patch and a text object without them stretching after adding it to a scene.

When I add one of the buttons from the asset store to my scene, I can re-size it and the 9-patch object repeats instead of stretching and the text object simply wraps instead of stretching. How do I do this with a custom object of my own? Haven’t seen any settings for that.

I never thought about it before. I looked at the slider control. It took some digging. I thought it might be one of the functions.

If you check the expand inner area… It resizes the control without scaling the child objects. It just changes what’s shown.

The fillbar child object has the anchor behavior. Custom objects are like self-contained scenes.

The thumb object of the slider also has an anchor behavior. I’m guessing the anchor is used a lot to keep the children in line.

1 Like

Yeah, I’ve been trying to make a custom button object that allows me to add more functionality (actions). The default “Labeled Button” object doesn’t allow you to add any functions of your own, so I thought I’d make a new custom object and just add a 9-patch and text to it so I can add my own actions (like change the font size of the label, color etc.).

Problem then becomes that when I add the custom object to a scene and try to re-size it, it doesn’t behave like the “labeled button” object because there seem to be some underlying code for it that’s making the it resizeable while keeping the 9-patch “tiling” functionality (non-stretched) in the scene editor.

Here’s a .gif of the issue of my custom object button:
stretching-custom-object

Did you check the expand inner area… and add the anchor behavior to the objects?

You can edit prefab controls, the issue is that you’d loose your changes if there was an update.

1 Like

Huh, interesting. I didn’t know the anchor behaviour actually shows results in the editor as well and not just in the game. Tried something before with it to replicate the buttons and felt it didn’t do anything so that’s why I disregarded it. But the anchor behaviour and expand inner area works together indeed.
Thanks for your time, appreciate it!

1 Like