Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: yuewah on September 27, 2012, 11:06:39 PM

Title: UIAnchor - Panel Container with UIRoot.Manual Height problem
Post by: yuewah 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.
Title: Re: UIAnchor - Panel Container with UIRoot.Manual Height is fixed
Post by: dlewis 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.
Title: Re: UIAnchor - Panel Container with UIRoot.Manual Height problem
Post by: yuewah on September 28, 2012, 03:54:07 AM
(https://dl.dropbox.com/u/9322397/Unity3d/ngui_anchor_1.png)
(https://dl.dropbox.com/u/9322397/Unity3d/ngui_anchor_2.png)

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"
Title: Re: UIAnchor - Panel Container with UIRoot.Manual Height problem
Post by: yuewah 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.  
Title: Re: UIAnchor - Panel Container with UIRoot.Manual Height problem
Post by: yuewah 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
Title: Re: UIAnchor - Panel Container with UIRoot.Manual Height problem
Post by: ArenMook 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.
Title: Re: UIAnchor - Panel Container with UIRoot.Manual Height problem
Post by: yuewah 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;
Title: Re: UIAnchor - Panel Container with UIRoot.Manual Height problem
Post by: nah0y on October 04, 2012, 09:37:32 AM
This has fixed problems for me, thanks yuewah !
Title: Re: UIAnchor - Panel Container with UIRoot.Manual Height problem
Post by: ArenMook on October 04, 2012, 10:47:56 AM
Hmm. Thanks, I'll add it to the main branch when I get back.