Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question coordinates entites in toolkit screen

Discussion in 'UI Toolkit' started by wphd, Jan 19, 2023.

  1. wphd

    wphd

    Joined:
    Aug 4, 2022
    Posts:
    9
    Hello,
    I need component or container coordinates in a toolkit screen to animate with DoTween.
    For example, I want to move entity A to position B.
    I looked at resolvedStyle, GeometryChangedEvent but I can't.
    Can you help me ?
     
  2. SimonDufour

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    609
    Hi! Is your animation a "fire and forget" thing? If so, you could just use the animation/transition system in UI toolkit to achieve what you want.

    If you want to drive the position of a visual element through code to fit with something in world space for example, you could use the method provided in UIElements.RuntimePanelUtils.

    Finally, you could check the position of a visual element using VisualElement.worldBound of ChangeCoordinatesTo if the coordinate to check for is between two visual elements.

    Let us know how we could help you, but providing more context would definitely be beneficial to understand what you are trying to achieve.
     
  3. wphd

    wphd

    Joined:
    Aug 4, 2022
    Posts:
    9
    Thank you for your quick reply.
    I want to be able to change entity locations dynamically (via c#) in a ui builder screen using doTween's generic functions.
    I'll be looking at UIElements.RuntimePanelUtils, specifically the ScreenToPanel function.
    Thanks for your help.
    What does a "fire and forget" thing mean? ...lol
     
  4. SimonDufour

    SimonDufour

    Unity Technologies

    Joined:
    Jun 30, 2020
    Posts:
    609
    It is an animation that would start and that you don't need to adjust or change as long as it is not finished. If you want to "float around the mouse position" and that the mouse move, you will need to adjust/modify the trajectory, so it is not fire-and-forget. On the opposite, USS transitions, deeply based on CSS transitions, are not really intended to be modified after they are lunched.

    you can look here for really simple transition : https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Transitions/Using_CSS_transitions

    and here for more advanced: https://blog.hubspot.com/website/css-animation-examples