Author Topic: Pop-ups reading the wrong scroll collider  (Read 3040 times)

Giantbean

  • Guest
Pop-ups reading the wrong scroll collider
« on: October 21, 2013, 04:25:30 PM »
I created a pop up that uses a scroll bar to move through text on a clipped plane (Example 7). This worked great however I need multiple full screen pop ups based on different selections (like email reader in mass effect or weapons details page in FarCry, one screen that opens sub screens containing scrollable content.) and when I create a second or third (etc. etc.) pop up with the attached scrolling capabilities they do not read. Instead I can see in the scenes window that my first pop up is scrolling while the play window shows no change to the active camera (full screen pop up).

I have searched the forums but to no avail.

I use tags in unity to swap between cameras setting camera.enabled = false or = true based on items clicked. This works to view different pop up windows however when I try to disable the hidden pop ups with SetActive(false) it does not work. This may be my lackluster understanding of the SetActive code structure however I am lost and thought one of you fine people on the Tasharen forum may know a better way to have multiple scroll bars in one scene. Anyone? Is this a NGUI feature or do I need to write a C# script? (I am new to code and don't yet know JavaScript) I would think NGUI would have a solution as I'm sure that I am not the first to want more than one pop up with scrolling text.

Thanks in advance for any suggestions on how I might solve this.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Pop-ups reading the wrong scroll collider
« Reply #1 on: October 21, 2013, 04:52:48 PM »
You can't nest clipped panels, if that's what you're trying to do. Otherwise I am just not following you correctly. Some pictures would help.

Giantbean

  • Guest
Re: Pop-ups reading the wrong scroll collider
« Reply #2 on: October 21, 2013, 07:02:45 PM »
I will try to get some screen shots tomorrow when I am back on the other PC.

They are not nested. I open only one pop up at a time. Each pop up is actually a GUI with its own camera and a scroll bar. Think of it as having 5 of the example 7 each one opens full screen when an object in the game is clicked. You close the pop up with an x in the top right corner before opening another pop up.

So only one GUI on screen at a time but the only one with a working scroll bar is the first one made.

It may have something to do with z depth as they all load full screen placing the scroll bar at in the same screen location when open, however they are not in the same x, y location in the screen window, just the game window.

Does that make any more sense or am I just confusing people?

Giantbean

  • Guest
Re: Pop-ups reading the wrong scroll collider
« Reply #3 on: October 22, 2013, 08:59:19 AM »
OK I have a screen shot that may help.

The scene window shows all the pop ups sitting below the game floor. items in the game have tags with onClick properties to change each GUIs camera.enabled to be true or false. When the camera is false you don't see the pop up. when it is true the pop up  GUI (labeled in the image 2-6 with 1 visible each time) covers the entire game screen as seen in the game window. (Content blurred for client protection)

I have labeled a few things
 Scene window labels
    1. The Close button that works on all pop ups.
    2. A basic UI panel without scrolling content
    3. Another basic UI panel without scrolling content
    4. UI panel with scrolling content
    5. Another UI panel with scrolling content
    6. Another UI panel with scrolling content

The UI panels with scrolling content have clipped panels and scroll bars like example 7.

Hierarchy Panel Lables
    1,2,3,5 Collapsed UI roots that correspond to the numbers in the Scene window.
    4, 6 Open UI roots showing the structure of the scrolling pop ups.

When the game plays I can open and close any of the screens however when I scroll the only one that works is the safety summary (#6) If I scroll on #4 or #5 I can see #6 scrolling in the Scene window however the active pop up in the game window is unmoved.

Does that make sense or do I need to post images of the Inspector as well?

Giantbean

  • Guest
Re: Pop-ups reading the wrong scroll collider
« Reply #4 on: October 22, 2013, 10:16:40 AM »
I just saw this on the Unity forums

"This has been resolved. The problem was with NGUI and not Unity, setactive doesn't work on NGUI panels correctly. I fixed it by using the supplied NGUITools.SetActive() method, hope that helps anyone else who might have encountered this problem "

This may be the root of my trouble. I will have to do some research and see what I come up with.


--Edit--

I tested this:

GameObject.Find ("SaftyAnchor").NGUITools.SetActive(false);

or

GameObject.Find ("SaftyAnchor").gameObject.NGUITools.SetActive(false);

 and got an error

Assets/BACN_AR_Files/Scripts/CS/ObjectHighlighter.cs(41,76): error CS1061: Type `UnityEngine.GameObject' does not contain a definition for `NGUITools' and no extension method `NGUITools' of type `UnityEngine.GameObject' could be found (are you missing a using directive or an assembly reference?)

So...? I'm lost.
« Last Edit: October 22, 2013, 11:59:51 AM by Giantbean »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Pop-ups reading the wrong scroll collider
« Reply #5 on: October 22, 2013, 07:47:05 PM »
NGUITools.SetActive(targetGameObject, true/false)

Just look at the signature for the function itself. Why post something this trivial?

Giantbean

  • Guest
Re: Pop-ups reading the wrong scroll collider
« Reply #6 on: October 23, 2013, 09:35:10 AM »
Because it is not trivial to me. I'm an artist not a programmer and I have no idea what you mean by look at the signature.

However thank you for the "NGUITools.SetActive(targetGameObject, true/false)" however testing this still does not work.

I can hide (deactivate) the target GameObject (which has never been an issue) however I can not  make it active again.

I have read up on SetActive in the Unity Script Reference, Answers and Forums but I don't see a scripting Reference for NGUI and I can't seem to get my issue resolved. If you have a tutorial or some other post that I have missed I would be happy to read/view it.

I'm sure your a very busy person and this may be trivial to you but it is important to me that I find a working solution.

Giantbean

  • Guest
Re: Pop-ups reading the wrong scroll collider
« Reply #7 on: October 23, 2013, 02:07:05 PM »
So no ideas?

I still cant get this working.

Here is a trimmed example of my code.

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class ObjectHighlighter : MonoBehaviour {
  5.      
  6.         bool isClicked = false;
  7.         GameObject ARCamera;
  8.         GameObject SaftyAnchor;
  9.         GameObject SpecsCamera;
  10.         GameObject CloseCamera;
  11.         GameObject baseObject;
  12.         string obj_name;
  13.         string layerName;
  14.        
  15.     // Use this for initialization
  16.     void Start () {
  17.                 SpecsCamera          = GameObject.Find( "SpecsCamera" );
  18.                 CloseCamera           = GameObject.Find( "CloseCamera" );
  19.                 SaftyAnchor           = GameObject.Find( "SaftyAnchor" );
  20.                 ARCamera              = GameObject.Find( "ARCamera" );
  21.  
  22.                                 ARCamera.camera.enabled = true;
  23.                                 SpecsCamera.camera.enabled = false;
  24.                                 CloseCamera.camera.enabled = false;
  25.                                 NGUITools.SetActive(SaftyAnchor, false);                                                                       
  26.     }
  27.  
  28.     // Turn on the bit using an OR operation:
  29.     private void Show( string layerName) {
  30.                 ARCamera.camera.cullingMask |= 1 << LayerMask.NameToLayer(layerName);
  31.  
  32.     }
  33.      
  34.     // Turn off the bit using an AND operation with the complement of the shifted int:
  35.     private void Hide( string layerName ) {
  36.         ARCamera.camera.cullingMask &= ~(1 << LayerMask.NameToLayer(layerName));
  37.  
  38.     }
  39.      
  40.     // Toggle the bit using a XOR operation:
  41.     private void Toggle( string layerName ) {
  42.         ARCamera.camera.cullingMask ^= 1 << LayerMask.NameToLayer(layerName);
  43.  
  44.     }
  45.                
  46.        
  47.     // Update is called once per frame
  48.     void Update () {
  49.  
  50.     }
  51.         //Calls the click event of Vuforia
  52.         void OnMouseDown () {
  53.         obj_name            = this.gameObject.name;
  54.         baseObject          = GameObject.Find( obj_name );
  55.         string obj_tag      = baseObject.gameObject.tag;  
  56.                
  57.         if (isClicked == false){
  58.                         switch (obj_tag)
  59.                         {                              
  60.                                 case "tag_SpecsPopUp": // Safty Summery
  61.                                         SpecsCamera.camera.enabled = true;
  62.                                         CloseCamera.camera.enabled = true;
  63.                                         GameObject.Find ("ImageTarget").GetComponent<TrackerPopup>().enabled = false;
  64.                                         GameObject.Find ("xRayButton").GetComponent<BoxCollider>().enabled = false;                                            
  65.                                         NGUITools.SetActive(SaftyAnchor, true);
  66.                                         isClicked = false;                             
  67.                                         break;
  68.                                
  69. // my full code has multiple other cases with tags allowing for game items to be clicked on and the user gets a pop up with info on the item
  70.                         }                            
  71.                }
  72.             else {
  73.                 switch (obj_tag)
  74.                         {                              
  75.                                 case "tag_SpecsPopUp": // Safty string
  76.                                         Hide ("SpecsPopUp");
  77.                                         ARCamera.camera.enabled = true;
  78.                                         SpecsCamera.camera.enabled = false;
  79.                                         GameObject.Find ("ImageTarget").GetComponent<TrackerPopup>().enabled = true;
  80.                                         NGUITools.SetActive(SaftyAnchor, false);
  81.                                         isClicked = false;                                     
  82.                                         break;
  83.                                
  84. //And of course more "else" cases that work with the other "if" cases when present
  85.                                
  86.                                 default:
  87.                                         Debug.Log ("default");                                 
  88.                                         break;
  89.                         }              
  90.             }
  91.     }
  92. }

From what I have read this should work but the deactivated object will not reactivate.

Is looking at the SetActive even the right path for solving my initial question? It seems to be the right solution but it just doesn't work.

Giantbean

  • Guest
Re: Pop-ups reading the wrong scroll collider
« Reply #8 on: October 23, 2013, 05:07:14 PM »
Alright! I fixed The above code just needed "Children"

Not NGUITools.SetActive(targetGameObject, true/false)

but NGUITools.SetActiveChildren(targetGameObject, true/false)

This could really use better documentation

I would think that the NGUITools changing the way Unity uses SetActive would be a topic for the frequently asked questions but apparently not many people run into this issue.

Any ways it works now. I hope others find this thread useful.