Author Topic: 3D anchoring in NGUI  (Read 4309 times)

kobilica

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 16
    • View Profile
3D anchoring in NGUI
« 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!

kobilica

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: 3D anchoring in NGUI
« Reply #1 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).

kobilica

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: 3D anchoring in NGUI
« Reply #2 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



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.  

kobilica

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: 3D anchoring in NGUI
« Reply #3 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..

kobilica

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: 3D anchoring in NGUI
« Reply #4 on: August 22, 2014, 04:58:02 AM »
Does anyone know how to disable automatic scaling of nGUI in 3D mode?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 3D anchoring in NGUI
« Reply #5 on: August 23, 2014, 02:46:39 AM »
Get rid of the UIRoot.