Search Unity

Unity UI Rotating and scaling UI image messes up anchors?

Discussion in 'UGUI & TextMesh Pro' started by xxPillsxx, Oct 21, 2017.

  1. xxPillsxx

    xxPillsxx

    Joined:
    Oct 10, 2012
    Posts:
    31
    I have a UI image and when I assign a texture to it, I want to show it in a certain way:

    I cannot rotate the original texture cause the UI Image is only a presentation of the actual object, which is a plane because I need to make complex effects which sprite renderer cannot support. However, the plane actually renders the object as shown in the third picture, while the UI Image renders it as shown in the second picture, so I need to rotate the UI Image element so it actually matches what the plane will render.

    While doing so kind of works (as shown above), it messes up with my anchors because the Canvas now sees the height as the width and vice versa. Before rotating it, I could anchor it so that the height scaled with the screen's height while the width stayed fixed, after rotating it it stretches the width instead while the height was fixed. I tried adjusting the anchors in so many ways but nothing worked.

    Any help would be appreciated.
     
  2. Brogan89

    Brogan89

    Joined:
    Jul 10, 2014
    Posts:
    244
    Try using Unity-UI-Extentions UIFlippable.

    As far as I've experienced rotating UI is massive headache you should try and avoid.
    As an example, I usually would created two images, one for horizontal, and one for vertical. Then I use UIFlippable make the change i want. So for a pointer, I'll have an arrow that points up, and one the points left. When I want the left arrow to point right Ill use the script and same if I want the up arrow to point down. Probably a very simplistic answer you'll get the gist.
     
    Kaldrin likes this.
  3. RBourbeau

    RBourbeau

    Joined:
    Nov 17, 2016
    Posts:
    1
    Hey xxPillsxx,
    You find a solution on how to rotate the UI images UVs without having it mess up the anchor system? I am having the same issue and was hoping this has been solved by the community. I want to use a single image to and be able to use it multiple ways, but when I rotate it also it messes up the anchoring system for multiple resolution devices.
    Any update on this? Thanks in advance.