Author Topic: Android anchors issue  (Read 1428 times)

roady

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 30
    • View Profile
Android anchors issue
« on: December 06, 2014, 10:53:21 AM »
I'm having issues with using anchors on android devices. It works in Unity Editor and multiple iOS devices.

But when exported and running on Android the position is seems to be wrong. I cannot see the item at all.

UIRoot properties
 - Scaling style: Constrained
 - Content width: 1536
 - Content Height: 1920
 - No fit

Hierachy
GAME
  UI Root (2D)
     Camera
         HUD (uipanel)
            button pause (uiwidget)

Button Anchors
 - Type: Unified
 - Execute: OnUpdate
 - Target: HUD
 - left: targets right -146
 - right: targets right -72
 - bottom: targets top -147
 - top: targets top -73


Tried to set a UIWidget in all 4 corners but none is showing.

When running debug on gameObject.transform.position

Unity: (0.4, 0.9, 1.0)
Android when removed anchors:  (0.4, 0.9, 1.0) this is showing
Android with anchors: (1.0, 1.9, 1.0)


Just to see where it is I set the position (1.0, 1.9, 1.0) in unity editor. You can see the inner rect and then top right that the button is way off.
« Last Edit: December 06, 2014, 10:58:49 AM by roady »

roady

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 30
    • View Profile
Re: Android anchors issue
« Reply #1 on: December 06, 2014, 11:47:24 AM »
Ops. Noticed that everything actually worked.  ;D

The issue was that when each panel started I have a script that tells all items to run MakePixelPerfect(); Guessing that if this is runned before NGUI has done its things the positions would be off.

This is fixed with a WaitForFixedUpdate:

IEnumerator Start() {
    yield return new WaitForFixedUpdate();
    retinaProUtil.sharedInstance.refreshAllWidgetsPixelPerfect(gameObject);      // fix up the visible and collider size