Author Topic: UIAnchor - Panel Container with UIRoot.Manual Height problem  (Read 7780 times)

yuewah

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 180
    • View Profile
UIAnchor - Panel Container with UIRoot.Manual Height problem
« on: September 27, 2012, 11:06:39 PM »
The UIRoot's manual height = 320 with automatic unchecked.
the gameobject under UIAnchor is not positioned right if I assign UIPanel in panel container.
« Last Edit: September 28, 2012, 10:57:30 AM by yuewah »

dlewis

  • Guest
Re: UIAnchor - Panel Container with UIRoot.Manual Height is fixed
« Reply #1 on: September 28, 2012, 12:23:26 AM »
You will need to describe how it is 'not positioned right' and possibly show screenshots to show what's happening.

yuewah

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 180
    • View Profile
Re: UIAnchor - Panel Container with UIRoot.Manual Height problem
« Reply #2 on: September 28, 2012, 03:54:07 AM »



using the NGUI example 1,
1. UIRoot's manual height = 320 with automatic unchecked
2. "Anchor - Bottom Left" Panel Container is assigned with "UIPanel - 2D"
« Last Edit: September 28, 2012, 10:57:46 AM by yuewah »

yuewah

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 180
    • View Profile
Re: UIAnchor - Panel Container with UIRoot.Manual Height problem
« Reply #3 on: September 28, 2012, 04:26:17 AM »
Just Fixed by modifying UIAnchor.cs

  1. UIRoot mRoot;
  2.  
  3. void Start ()
  4. ...
  5.    mRoot = NGUITools.FindInParents<UIRoot>(gameObject);
  6. }
  7.  
  8. void Update ()
  9. ...
  10.       if (panelContainer.clipping == UIDrawCall.Clipping.None)
  11.      {
  12.            rect.xMin = -Screen.width * 0.5f * mRoot.manualHeight / Screen.height;
  13.            rect.yMin = -Screen.height * 0.5f * mRoot.manualHeight / Screen.height;
  14.  
  15.  
  16. ...
  17. }
  18.  
« Last Edit: September 28, 2012, 10:58:04 AM by yuewah »

yuewah

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 180
    • View Profile
Re: UIAnchor - Panel Container with UIRoot.Manual Height problem
« Reply #4 on: October 01, 2012, 08:59:52 AM »
@ArenMook, could you have a look on my problem ? And see if my code change can added to the official release

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIAnchor - Panel Container with UIRoot.Manual Height problem
« Reply #5 on: October 01, 2012, 04:51:04 PM »
I've already added it to the main repo, you'll see it in the next release.

yuewah

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 180
    • View Profile
Re: UIAnchor - Panel Container with UIRoot.Manual Height problem
« Reply #6 on: October 03, 2012, 09:58:28 PM »
After updated to v2.2.2, there are a few problem

1. sometime the ratio become zero because mRoot.manualHeight is INT

  1. float ratio = (mRoot != null) ? mRoot.manualHeight / Screen.height * 0.5f : 0.5f;
=>
  1. float ratio = (mRoot != null) ? (float)mRoot.manualHeight / Screen.height * 0.5f : 0.5f;

2. the anchored GameObject does not follow to the UIPanel outside the Screen.
  1. float oldZ = v.z;
  2. if (widgetContainer != null)
  3. {
  4.         v = widgetContainer.transform.parent.TransformPoint(v);
  5.                                
  6. }
  7. else if (panelContainer != null)
  8. {
  9.         v = panelContainer.transform.parent.TransformPoint(v);
  10. }
  11.  
  12. v.z = oldZ;
=>
  1. //float oldZ = v.z;
  2. if (widgetContainer != null)
  3. {
  4.         v = widgetContainer.transform.TransformPoint(v);
  5.                                
  6. }
  7. else if (panelContainer != null)
  8. {
  9.         v = panelContainer.transform.TransformPoint(v);
  10. }
  11.  
  12. //v.z = oldZ;
« Last Edit: October 04, 2012, 04:10:51 AM by yuewah »

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: UIAnchor - Panel Container with UIRoot.Manual Height problem
« Reply #7 on: October 04, 2012, 09:37:32 AM »
This has fixed problems for me, thanks yuewah !

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIAnchor - Panel Container with UIRoot.Manual Height problem
« Reply #8 on: October 04, 2012, 10:47:56 AM »
Hmm. Thanks, I'll add it to the main branch when I get back.