Author Topic: clip problem in UIPanel with stretch  (Read 3199 times)

WinMain

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 6
    • View Profile
clip problem in UIPanel with stretch
« on: July 29, 2012, 11:08:26 PM »
hi,our game use 1024*768 resolution in IPAD,that no problem,but now we want to use out layout in android's pad device,there resolution ratio are not same,like 1280*800 1280*600 and so on.We don't want to make many size layouts and images for so many resolution,we just want to stretch them,so I modify the UIRoot.cs like this:
  1. manualHeight = Mathf.Max(2, Screen.height);
  2.                 //manualWidth = Mathf.Max(2, Screen.width);
  3.  
  4.                 float size = 2f / manualHeight * ((float)manualHeight / 768);
  5.                 float sizeX = (float)Screen.width / 1024 * 2f / manualHeight;
  6.                 Vector3 ls = mTrans.localScale;
  7.  
  8.                 if (!Mathf.Approximately(ls.x, sizeX) ||
  9.                         !Mathf.Approximately(ls.y, size) ||
  10.                         !Mathf.Approximately(ls.z, size))
  11.                 {
  12.                         mTrans.localScale = new Vector3(sizeX, size, size);
  13.                 }
en,it worked fine as I want,but all my drag list in uipanel are wrong,the cliprect is not correct,their children out the clip rect and still visible,how can I do to make it correct.I use NGUI ver1.82.Waitting for help,thank you.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: clip problem in UIPanel with stretch
« Reply #1 on: July 29, 2012, 11:16:49 PM »
Scaling must be uniform. You're running into a Unity limitation here, it has to do with how Unity sends the matrix to the shader. If the scale is not uniform, it breaks.

What you should do instead is use UIAnchor to attach things to corners and sides of the screen, thus making your UI modular.