How to get node size after it is instantiated?

Hello!

I’m wondering if anyone here knows how one can get the node size after it is being created. I’ve tried the following methods but they do not return any useful value:

  • GetPosition().width (returns 0)
  • node.style.width.value.value (returns NaN)
  • node.resolvedStyle.width (returns NaN)

Is there any other way for me to read the nodes current width? Thanks in advance!

Hello D-DutchDave,

see this post: How to get the actual width and height of an uielement?

Using the GeometryChangedEvent and thereafter working with the layout property worked for me in Unity 2021.3 for getting the actual size of the VisualElement.