Author Topic: 3D side by side  (Read 4463 times)

brotentech

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 5
    • View Profile
3D side by side
« on: May 19, 2014, 01:16:54 AM »
I have my NGUI set up to draw out two UI's side by side. This is because my game is running 2 viewports to support 3D output.

I've got user input restricted to viewport 1 only.
When I interact with a UI object on viewport 1, I need to make the viewport 2 UI elements state mirror that of viewport 1. As they are 2 components of the same interface.

I previously used one UI with two camera, but I've since duplicated the UI to allow some elements to have 3D effects.

examples.

Checkbox1, is clicked and checked. Checkbox2 must also check.
Slider1, moves. Slider2 must move to match.

brotentech

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 5
    • View Profile
Re: 3D side by side
« Reply #1 on: May 19, 2014, 01:39:14 AM »
Here is the start of the code I just made up.
Any ideas on how to assign a target and change it's state?

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class NGUIMatchUIstate : MonoBehaviour {
  5.  
  6.         private string text;
  7.         private bool ischecked;
  8.  
  9.         public void OnChangeText ()
  10.         {
  11.                 // get text value
  12.                 text = UIInput.current.value;
  13.  
  14.                 // set text value to target
  15.  
  16.  
  17.                 //Debug Log
  18.                 Debug.Log ("NGUI: " + text);                   
  19.         }
  20.        
  21.         public void OnChangeCheckBox ()
  22.         {
  23.                 // get checked value
  24.                 ischecked = UIToggle.current.value;    
  25.  
  26.                 // set checked value to target
  27.  
  28.  
  29.                 //Debug Log
  30.                 Debug.Log ("NGUI: " + ischecked);              
  31.         }
  32.  
  33. }

brotentech

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 5
    • View Profile
Re: 3D side by side
« Reply #2 on: May 19, 2014, 01:54:05 AM »
The current script, using On Change Notify is receiving the values.
What I need to do next is set a TARGET, and pass those values to it.

brotentech

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 5
    • View Profile
Re: 3D side by side
« Reply #3 on: May 19, 2014, 02:07:16 AM »
Well figured out the OnChangeText method!  :D

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class NGUIMatchUIstate : MonoBehaviour {
  5.  
  6.         private string text;
  7.         private bool ischecked;
  8.  
  9.         public void OnChangeText (GameObject arg0)
  10.         {
  11.                 // get text value
  12.                 text = UIInput.current.value;
  13.  
  14.                 // set text value to target
  15.  
  16.                 UIInput texttarget = arg0.GetComponent<UIInput>();
  17.                 texttarget.value = text;
  18.  
  19.                 //Debug Log
  20.                 Debug.Log ("NGUI: " + text);                   
  21.         }
  22.        
  23.         public void OnChangeCheckBox ()
  24.         {
  25.                 // get checked value
  26.                 ischecked = UIToggle.current.value;    
  27.  
  28.                 // set checked value to target
  29.  
  30.  
  31.                 //Debug Log
  32.                 Debug.Log ("NGUI: " + ischecked);              
  33.         }
  34.  
  35. }

brotentech

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 5
    • View Profile
Re: 3D side by side
« Reply #4 on: May 19, 2014, 02:36:12 AM »
Well I now got NGUI working 100% on a 3D display. both game environment and UI are presenting in 3D. with UI elements and Cursor having various 3D depths. Looks really nice.