#Anyone know how to fix or suppress a "_set_size" warning?

1 messages · Page 1 of 1 (latest)

stray summit
#

I'm getting a bunch of this warning coming up and it makes it really annoying to spot any actual issues. I've tried changing the anchors and using set_deffered but neither seem to make a difference.

W 0:00:06:754 _set_size: Nodes with non-equal opposite anchors will have their size overridden after _ready().
If you want to set size, change the anchors or consider using set_deferred().
<C++ Source> scene/gui/control.cpp:1443 @ _set_size()

This is the function that seems to be causing it, it's called from set_text and just resizes a custom tooltip based on the actual size of the text.

func resize() -> void:
label.custom_minimum_size = Vector2(label.get_content_width(), label.get_content_height())
label.size = label.custom_minimum_size
margin_container.custom_minimum_size = label.size + Vector2(10,10)
margin_container.size = margin_container.custom_minimum_size
custom_minimum_size.x = label.size.x + 18
set_deferred("size", custom_minimum_size)
label.text = "[center]" + label.text + "[/center]"

sacred sand
#

I think you need @warning_ignore("_set_size") ? never had the error so I don't know the name of the warning to ignore, otherwise why don't you use an actual Label ? it would change its size based on the text automatically

stray summit
#

I can't find the right warning, none of the ones that come up on autocomplete look right.

I'm using a rich text label because i want to be able to format individual sections independently (larger font for the title than the body of text, for example).

mystic jay
#

As ferminou says, it's better to design the box properly with a tscn, but if you insist..

func resize() -> void:
    label.custom_minimum_size = Vector2(label.get_content_width(), label.get_content_height())

    margin_container.custom_minimum_size = label.custom_minimum_size + Vector2(10,10)

    custom_minimum_size.x = label.custom_minimum_size.x + 18
    label.text = "[center]" + label.text + "[/center]"

    label.set_deferred(&"size", label.custom_minimum_size)

    margin_container.set_deferred(&"size", margin_container.custom_minimum_size)

    set_deferred(&"size", custom_minimum_size)

.

stray summit
#

I'm not sure what you mean by "design the box properly with a tscn", the tooltip panel is a custom scene. Your suggested code does look like an improvement but the warnings still appear, so it seems like the suggestion to use set_deferred() is a red herring

mystic jay
#

(oops I made a typo with that \n character, but you get the idea!)

stray summit
#

This is almost good but I want the text to wrap dynamically rather than displaying in a single long line, it's being used for tooltips and I don't want to have to manually typeset hundreds of lines. If I use the word wrapping with your solution it just shrinks to 0 width, I can define a custom minimum width to get around that but then lines that are shorter than that have a bunch of unnecessary padding, this is the problem my custom solution was trying to solve.

mystic jay
#

I think the solution is to get rid of the set_deferred and call the entire function deferred instead

resize.call_deferred()

I tried both the tscn and custom code side by side with the same text source, they behave the same other than some random variation on the width? Probably a good idea to make a test run for all the game texts to confirm it works how it's supposed to.