Home Game Development unity – Why does this Get Size Delta of a Rect Transform all the time return a worth of zero when referred to as on Start?

unity – Why does this Get Size Delta of a Rect Transform all the time return a worth of zero when referred to as on Start?

0
unity – Why does this Get Size Delta of a Rect Transform all the time return a worth of zero when referred to as on Start?

[ad_1]

I’ve the next Unity Visual Script triggered on a Start:

enter image description here

It seems at a toddler GameObject that makes use of Rect Transform and has a Text Mesh Pro part, and makes an attempt to calculate the width of the textual content utilizing the Get Size Delta of the Rect Transform.

Here’s the odd factor: the connected script all the time returns a width of 0. I feel that is as a result of the script is triggered on Start, and by then possibly the anchors have not been set but. That’s my idea at the very least, as a result of if I run this very same code on one other occasion apart from Start… the Size Delta returns acceptable information, and it all the time calculates the width correctly.

I’m fairly positive I may set some kind of time-based delay, and I’d get the correct outcomes… however I’d like to know the problem higher and never simply kludge it.

When precisely do anchor factors get set? Is there a method I may name this code in such a method that it persistently generates a width that is non-zero?

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here