Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: beermoney on May 19, 2014, 09:08:05 AM
-
Hi,
I don't seem to be able to be able to set unified anchors correctly when in "portait" mode. I was going to attach a project but its fairly simple to reproduce...
(Version 3.5.9)
1. Add portrait (1536 x 2048) resolution to the list of game resolutions, use that resolution
2. Add Coloured Button from the NGUI prefabs into an empty scene (this creates the UIRoot and camera etc)
3. Set the screen height in the UIRoot to 2048.
4. Set the anchor of the button UISprite to "Unified", by default the buttons are anchored to the UIRoot center
5. Drag the button to the top right corner of the screen, hit play and confirm the button appears where expected (wysiwyg)
6. Change the anchoring of the button's UISrpite to the "Target's Right" for the left and right and "Target's Top" for the bottom and the top. Run the project and the button jumps to the top center not the top right as expected.
Thanks
-
Works as expected here... I didn't specify a portrait resolution, I simply undocked the window and resize it so that it's in a portrait mode (height larger than width). I created a sprite, put it in the top right corner, chose Unified, and it stays there when I resize the game window.
Make sure your game view is not hidden behind your scene view.
-
1) unless you have a godly monitor, you won't have the resolution on your screen. Your game window will be smaller than that (click stats to see the real size).
If you want a sprite to stay at the top right corner, you have to set
anchor right - target right
anchor left - target right
anchor top - target top
anchor bottom - target bottom.
And make sure to have whatever offset is needed if your pivot is center on the sprite.
If you want to anchor at a higher level in the hierarchy (say if the button is an empty gameObject and the children are a sprite and a label) then add a UIWidget to that button and give it a size - then you can anchor that in the same manner.