Author Topic: Culling Mask being changed inside NGUI?  (Read 2023 times)

badawe

  • Jr. Member
  • **
  • Thank You
  • -Given: 8
  • -Receive: 7
  • Posts: 70
    • View Profile
Culling Mask being changed inside NGUI?
« on: March 23, 2015, 02:45:08 PM »
Hey guys, this is driving me nuts, the hole scenario is, I had a really complex UI, with a lot of elements and about 5 cameras.

One of this is responsible for the Alert Popups, like everything else in this UI I'm using a lot of PoolableObjects, so just to get an Idea of what looks like, is something like that:




In my Alert Camera, I had the Event Mask only marked to the Alert Layer, and in my Camera, the same, this is suppose to only render and interact with the Alert Objects.

And in the initiation of this objects from the pool, I do exactly like NGUITools.AddChild, but I do in my own way, to get the object from the Pool:

  1.  /// <summary>
  2.     /// Display an decision box with 2 choices
  3.     /// </summary>
  4.    /// <param name="title">title of the screen</param>
  5.    /// <param name="content">Target text to be displayed</param>
  6.     /// <param name="button1Label">Label of the button 1</param>
  7.     /// <param name="button2Label">Label of button 2</param>
  8.     /// <param name="button1Callback">Callback for the button 1</param>
  9.     /// <param name="button2Callback">Callback for the button 2</param>
  10.     /// <param name="showOverlay"></param>
  11.     /// <returns></returns>
  12.    public static DecisionAlert ShowDecision(string title, string content, string button1Label, string button2Label, Action button1Callback, Action button2Callback, bool showOverlay = true)
  13.    {
  14.        DecisionAlert alert = ObjectPoolController.Instantiate(Instance.AvaliableAlerts[(int)AlertTypes.Decision].gameObject).GetComponent<DecisionAlert>();
  15.        alert.transform.parent = Instance.ContentTable.transform;
  16.        alert.transform.localScale = Vector3.zero;
  17.        alert.transform.localPosition = Vector3.zero;
  18.        NGUITools.MarkParentAsChanged(Instance.ContentTable.gameObject);
  19.  
  20.        alert.Init(title, content, button1Label, button2Label, button1Callback, button2Callback);
  21.        if (showOverlay)
  22.        {
  23.            ShowOverlay();
  24.        }
  25.  
  26.        Instance.m_activeAlerts.Add(alert);
  27.        
  28.        return alert;
  29.     }

Now is the strange part, i had a simple button to test this, and keep adding this to the view, and test it out. If i press this button a bunch of times, everything goes perfect, but when I close this Alerts (Pressing the Close button) and try to add a new one, this new one comes from the Pool, and then something strange happen.
My camera lost his Culling Mask, a new UIRoot is created with a new Panel, and from now on, If i remove the new UIRoot, and add one more, the UIRoot is created again.


I do this in mostly every part of the project, but only this one is giving me this problem.

Someone know what can be?

I'm using the 3.8.1 version and Unity: 4.6.3f1

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Culling Mask being changed inside NGUI?
« Reply #1 on: March 24, 2015, 10:33:07 AM »
NGUI creates a root if one is not readily available. Check this topic: http://www.tasharen.com/forum/index.php?topic=12768.msg57955#msg57955