Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: galuodo on September 06, 2013, 05:16:36 AM
-
When I set the position of a game object, it works well at first. However after I used UIAnchor so that the game can be fit other resolution, the positions have a large deviation after the resolution changed.
void Update () {
ul
.transform.position = sp
.transform.position+ new Vector3
(5,
5,
0); }
-
Remember to set localPosition for UI stuff. Position is the global position which may vary and make no sense.
-
Thanks for your reply.
but i need world position to set underline or detect the location of mouse cursor and something else with out colliders, what should I do next?
-
Well then you have to convert between local space and global space and maybe even screen space to be able to match everything. Setting some position + Vector3(5,0,0) can mean quite a difference when set in global space. Remember that NGUI operates in a very small global area (2 / UIRoot.activeHeight) so you should calculate how much you want to move in localSpace and convert to global.
I think there's a bunch of helper methods in NGUITools and NGUIMath that can help you as well.