RectTransform.sizeDelta confusion

Hi, I have a uGUI Image and I want to konw the size from code.

if I place the anchors together:
In the IDE: The parameters width and height are the size of the image.
In the code: sizeDelta has the size of the Image, that is what I want in my code.

If I place the anchor points in the corners of the image:
Unity IDE: The parameters width and height are 0
In the code: sizeDelta’s x and y is 0.

What if I want to know the size of the image with the anchor points in the corners of the image?
Is not possible?
The documentation says the following:

I think that explanation is confusing, the meaning of the word “parent” is not clear in this case. “sizeDelta is the same as size” what is size? a parameter? how do I get that from code?

1 Like

i need to know this too, apparently everybody suggest using sizeDelta to set the size, but I have the anchor points split 4 ways to the corners of my UI element. The sizeDelta is always 0,0.

Is there a formula that takes into account setting width and height while also having split anchors?

@whoOisOdis

Necro posting…

And wrong forum.

This is a UI / uGUI question.

Usually you can’t simply use sizeDelta (because of above mentioned reasons).

If you simply google “unity get RectTransform size” you’ll find how to get the actual size properties of RectTransform, IIRC there are several ways to get the size.