Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Asse on June 08, 2012, 05:08:26 AM

Title: Resolution change not recognized on mobile devices
Post by: Asse on June 08, 2012, 05:08:26 AM
Hey,

Sometimes I have problems with the resolution on mobile devices. When UIRoot.automatic is set to true it keeps the old manualHeight.

What I've noticed also in other projects, is that Mathf.Approximately isn't very accurate on mobile devices. So when I change to following code in UIRoot from

  1. void Update ()
  2. {
  3.         manualHeight = Mathf.Max(2, automatic ? Screen.height : manualHeight);
  4.  
  5.         float size = 2f / manualHeight;
  6.         Vector3 ls = mTrans.localScale;
  7.  
  8.         if (!Mathf.Approximately(ls.x, size) ||
  9.                 !Mathf.Approximately(ls.y, size) ||
  10.                 !Mathf.Approximately(ls.z, size))
  11.         {
  12.                 mTrans.localScale = new Vector3(size, size, size);
  13.         }
  14. }

to

  1. void Update ()
  2. {
  3.         manualHeight = Mathf.Max(2, automatic ? Screen.height : manualHeight);
  4.  
  5.         float size = 2f / manualHeight;
  6.         Vector3 ls = mTrans.localScale;
  7.  
  8.         if( !(Mathf.Abs( ls.x - size ) <= float.Epsilon ) ||
  9.                 !(Mathf.Abs( ls.y - size ) <= float.Epsilon ) ||
  10.                 !(Mathf.Abs( ls.z - size ) <= float.Epsilon ))
  11.         {
  12.                 mTrans.localScale = new Vector3(size, size, size);
  13.         }
  14. }

everything works like a charm.

Anybody else can confirm this?
Title: Re: Resolution change not recognized on mobile devices
Post by: ArenMook on June 08, 2012, 01:48:32 PM
Seems harmless enough.