Rectangle/offset width is not scaling/does not respects the window resize

Hey guys, so I have an issue an I am not sure how to fix it.

So I am using Rectangle in order to show health bar under the mesh (linkWithMesh) and that Rectangle has also added control from AdvancedDynamicTexture.CreateFullScreenUI.

And things are fine since it shows the bar, I am setting the offsets like that:

  const advancedTexture = AdvancedDynamicTexture.CreateFullscreenUI("ui1");

const offset = 100;
  const container = new Rectangle("myrectangle");
  container.width = "100px";
  container.height = "12px";
  container.color = "black";
  container.linkOffsetY = offset;

But the moment lets says I will resize the browser window and make it smaller, the mesh is scaled correctly but rectangle stays the same, which means that it ends up being too big and the offset is waaaay to far away from the target.
How can I make it so it scales dynamicaly? and actually respects the resizing?

Best would be if you could share a PG. There could be a number of reasons for it (eventually adding to each). The first thing I’m thinking is that you are fixing the width in pixels on the FS UI. Basically, it wouldn’t rescale from the window/canvas size with a fixed size. There are other things around the ideal size for rendering and also updating the ADT. You could be missing some parts of these as well. I also remember there was something (just something) going on with the resize/refresh of the rectangle container. Can’t recall what it was exactly, may be cc @carolhmj (our gui angel :innocent:) does :grinning:… Else, you could search the forum with some keywords around ‘rectangle’ + ‘resize’ or something.
But then again, if by any means, you could make just a small, quick and dirty :grin: PG, it shouldn’t be all too long until we can fix it. Meanwhile, have a great day :sunglasses:

1 Like