Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Rotating a visual element doesn't rotate its bounds

Discussion in 'UI Toolkit' started by b4gn0, Oct 15, 2020.

  1. b4gn0

    b4gn0

    Joined:
    Jul 26, 2019
    Posts:
    119
    Hello,

    We are trying to show a dotted line on screen (simple image) and clip it using a container visual element set with overflow: hidden.

    This line has to rotate. We rotate the container by setting its .transform.rotation, and the image appears correctly rotated.
    However, while the image is correctly rotated, the container clips the image using its un-rotated rectangle form.

    Correct behaviour:
    upload_2020-10-15_15-25-51.png

    Incorrect behaviour (notice the line is cut at the start and end)
    upload_2020-10-15_15-26-13.png

    The debugger shows the container as if it didn't rotate:
    upload_2020-10-15_15-26-56.png

    We applied a workaround by increasing the size in the width direction, but it seems like an incorrect behaviour to begin with.

    Thank you
     
  2. SimonDufour

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    515
    Hi,

    The clipping is currently not aware of the transform.rotation. We have a full overhaul of the rotation that will add more features that will begin soon.

    For the moment, is there any specific reason you are using the overflow:hidden flag? I think that by disabling that you will have the wanted result.
     
  3. b4gn0

    b4gn0

    Joined:
    Jul 26, 2019
    Posts:
    119
    Hi @SimonDufour , sorry if it wasn't clear, but the actual image is a very long line, much longer than the container, thus it needs to be cropped.
     
  4. SimonDufour

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    515
    I see :(

    We are aiming to have an API to do primitives, and also to implement the rotation with the clipping in the near future. Both would be more elegant solution to what you are doing.

    In the meantime, you could use the meshAPI to generate your own lines or even include some IMGUI container to draw them dynamically, but both would probably be harder to implement than just adjusting the size of the container based on the angle as you proposed.
     
  5. b4gn0

    b4gn0

    Joined:
    Jul 26, 2019
    Posts:
    119
    Thank you anyways, glad you are working it!
     
  6. Weidz_

    Weidz_

    Joined:
    Feb 15, 2018
    Posts:
    40
    Is it a thing now ?
     
  7. uMathieu

    uMathieu

    Unity Technologies

    Joined:
    Jun 6, 2017
    Posts:
    384
    Rect clipping is still axis-aligned as of 2022.2
     
  8. AlexandreT-unity

    AlexandreT-unity

    Unity Technologies

    Joined:
    Feb 1, 2018
    Posts:
    323