Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: kobilica on August 21, 2014, 08:44:35 AM

Title: 3D anchoring in NGUI
Post by: kobilica on August 21, 2014, 08:44:35 AM
Hello, little question. Old Anchoring system works but I can't use advanced functions like in new Anchoring system. Problem is, new anchoring system in no way works with 3D, as it still acts like it is 2D...

Did I miss something?

Thanks!
Title: Re: 3D anchoring in NGUI
Post by: kobilica on August 21, 2014, 10:12:08 AM
Ok I see I can anchor widgets inside another widgets just fine like in 2D, but main problem is still here.. everytime I anchor widget to the panel, it just gets f*ck up (basically, it is useless).

I really want this anchoring, old anchoring system works nice but it lacks features (responsive layout).
Title: Re: 3D anchoring in NGUI
Post by: kobilica on August 22, 2014, 02:54:53 AM
I DID IT!!  ;D ;D :D :o

I did a simple "hack" / "trick".. here it is for future in-case anyone wants to make rad 3D UI

(http://i.imgur.com/0P2g7gj.png)

And the code for UIFakePanel

  1. using UnityEngine;
  2.  
  3. [ExecuteInEditMode]
  4. public class UIFakePanel : UIWidget {
  5.  
  6.     public UIPanel parentPanel;
  7.  
  8.     private int prevWidth;
  9.     private int prevHeight;
  10.  
  11.  
  12.     void FindPanel() {
  13.  
  14.         parentPanel = transform.parent.GetComponent<UIPanel>();
  15.  
  16.         if (parentPanel == null) {
  17.  
  18.             Debug.LogError("Please put Fake panel just above real Panel");
  19.         }
  20.     }
  21.  
  22.     void Awake() {
  23.  
  24.         parentPanel = transform.parent.GetComponent<UIPanel>();
  25.  
  26.         if (parentPanel == null) {
  27.            
  28.             Debug.LogError("Please put Fake panel juset above real Panel");
  29.         }
  30.     }
  31.  
  32.         void Update () {
  33.  
  34.         if(parentPanel == null)
  35.             FindPanel();
  36.  
  37.             if (prevWidth != (int) parentPanel.width || prevHeight != (int) parentPanel.height) {
  38.  
  39.                 SetDimensions((int) parentPanel.width, (int) parentPanel.height);
  40.  
  41.                  prevWidth = (int) parentPanel.width;
  42.                 prevHeight = (int) parentPanel.height;
  43.             }
  44.         }
  45. }
  46.  
Title: Re: 3D anchoring in NGUI
Post by: kobilica on August 22, 2014, 04:52:35 AM
Nope, the whole system doesn't scale properly. It works excellent when changing widths but when changing height, it just doesn't scale properly..
Title: Re: 3D anchoring in NGUI
Post by: kobilica on August 22, 2014, 04:58:02 AM
Does anyone know how to disable automatic scaling of nGUI in 3D mode?
Title: Re: 3D anchoring in NGUI
Post by: ArenMook on August 23, 2014, 02:46:39 AM
Get rid of the UIRoot.