Resonite-Issues icon indicating copy to clipboard operation
Resonite-Issues copied to clipboard

RectSlotDriver does not respect UnitScale

Open shdwx-dev opened this issue 1 year ago • 4 comments

Describe the bug?

When a canvas has a UnitScale != 1.0, RectSlotDrivers move slots to incorrect positions. At a UnitScale of 1000 for example, slot positions are 1000 times greater than they should be (on the example item below, a slot is positioned at 120m on the X axis when it should be 0.120m).

To Reproduce

Spawn this item: resrec:///U-ShadowX/R-dd8b9359-125c-42c5-b90b-1f397593753d and inspect it. The two outer boxes are not visible because they are incorrectly positioned. Changing the UnitScale and Size of the canvas and scaling it accordingly resolves the problem.

Expected behavior

Slots are positioned correcty and are generally closer to the canvas root when UnitScale is bigger

Screenshots

No response

Resonite Version Number

Beta 2024.1.27.608

What Platforms does this occur on?

Windows

What headset if any do you use?

Quest 2

Log Files

N/A, not an exception-related bug as far as I can tell

Additional Context

Seems like it would be a quick fix, possibly as simple as dividing the end position by the UnitScale

Reporters

ShadowX @shdw_x

shdwx-dev avatar Jan 27 '24 14:01 shdwx-dev

I've found an alright workaround until this gets actually fixed image

shdwx-dev avatar Jan 27 '24 19:01 shdwx-dev

I don't know if this should be a different issue report but, Button.GlobalPosition and Button.LocalPosition also don't respect UnitScale either. (Internally neither does RectTransform.ComputeGlobalComputeRect())

If this issue didn't exist I was going to make an issue reporting both RectSlotDriver and the button event positions not respecting UnitScale

I made an item here that demonstrates both the button events and the RectSlotDriver resrec:///U-badhaloninja/R-4554D1876446EF28FC5CCFA7C02292A37184BC99165EF105885CAB03181AD030

I assume ProjectedRectSlotDriver has the same problem but I did not check

Here is a video of me demonstrating the object I made,

For the green button

  • Red spheres are the button event's global position unchanged (the radius of the visual is scaled based on distance)
  • Green spheres are the local position after I compensate for UnitScale and transform local to global, this is the expected location
  • The white line is the difference between them

For the blue square

  • The red line is a slot segment mesh pointing from the expected location, to the actual RectSlotDriver slot

https://github.com/Yellow-Dog-Man/Resonite-Issues/assets/1661241/d13fbb94-8aca-4875-b54b-a5ce91798269

badhaloninja avatar Feb 13 '24 20:02 badhaloninja

Seeing what happened with the user inspector issue having a somewhat misleading name, I feel this issue's title should be changed to reflect that more generally rect transform's computed positions are not compensated for unit scale instead of just the RectSlotDriver not working

badhaloninja avatar May 23 '25 12:05 badhaloninja

@badhaloninja you know much more about the internal causes for this issue than I do, so if you could suggest a new title I'd happily change it

shdwx-dev avatar May 23 '25 22:05 shdwx-dev