Hello everyone, I’m trying to develop a graphical interface that adjusts according to the device’s orientation. The elements remain the same, but their style is changed to fit the right UI for the new orientation.
To do this, I’ve created two USS, “landscapeUSS” and “portraitUSS,” and two TSS, “LandscapeTSS” and “PortraitTSS.” Naturally, in “LandscapeTSS,” only “landscapeUSS” is present, and the same goes for the other TSS.
I’m monitoring orientation changes through a script in the “Update()” function, checking “Input.DeviceOrientation.” When the device switches to “portrait,” I set “portraitTSS” in the settings panel, and vice versa.
Everything seems to “work,” but not entirely: unfortunately, when transitioning from “portrait” (the default orientation) to “landscape,” the UI elements do not rotate but remain in the same direction as “portrait.”
Is there a method to resolve this issue? Is there something missing in my code, or should I work around the problem by considering the “horizontal direction” differently?
I’m leaving these examples here, which are screenshots taken on the device:
with a simple example (3 VisualElements and a Label, no style override), I was able to have to rotation between landscape/portrait working (i.e.: the label is correctly oriented when I rotate the device).
Are you using “Auto Rotation” in Player settings ?
Sorry, I don’t have the “auto-rotate” enabled on my phone. Did u know if there is something I can do to check if the device has the “auto-rotate” enabled or force it to enable?