Author Topic: Pulling widgets forward through script  (Read 3867 times)

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Pulling widgets forward through script
« on: June 18, 2014, 09:54:00 AM »
Hi,

I'm having a depth problem with NGUI version 3.5.6. I'm using LocalNotifications, and when the app receives a LocalNotification it starts the app and should go to appropriate panel (screen). The panel can also be accessed through menu and that works fine. What happens is when the localnotification triggers the callback (so i know which localnotification is fired) it tweens to the correct panel but the screen stays white. I debugged it and I know for sure the panel = active, the panel position is Vector3.zero so it's on screen. Is there any way to pull all widgets in a screen forward?

So OnLocalNotificationFired("WMoment") is the one i'm testing right now.

Here's my code:

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class LocalNotifCallbacks : MonoBehaviour {
  5.  
  6.         public AppSettings settings;
  7.         public WeightRegistrationManager WRM;
  8.         public SlideMenuManager SMM;
  9.         public DatabaseEventManager DEM;
  10.  
  11.         public GameObject[] PanelWidgets;
  12.  
  13.         public UIButton[]       WMButtons,
  14.                                 MotivButtons;
  15.  
  16.         private GameObject activePanel;
  17.         private Vector3 panelVector;
  18.  
  19.         private EventDelegate   evi,
  20.                                         WMEvi;
  21.  
  22.  
  23.         private void Start()
  24.         {
  25.                 if(!PanelWidgets[30].gameObject.activeSelf)
  26.                         panelVector = PanelWidgets[30].transform.localPosition;
  27.                 else
  28.                         panelVector = PanelWidgets[29].transform.localPosition;
  29.  
  30.                 evi = new EventDelegate(this, "TurnOff");
  31.                 evi.oneShot = true;
  32.  
  33.                 WMEvi = new EventDelegate(this, "TurnOffWM");
  34.                 evi.oneShot = true;
  35.         }
  36.  
  37.         #if UNITY_IPHONE
  38.         public void OnEnable() {
  39.                 LocalNotifs.OnLocalNotificationFired += OnLocalNotificationFired;
  40.                 LocalNotifs.OnSetLocalNotification += OnSetLocalNotification;
  41.         }
  42.         public void OnDisable() {
  43.                 LocalNotifs.OnLocalNotificationFired -= OnLocalNotificationFired;
  44.                 LocalNotifs.OnSetLocalNotification -= OnSetLocalNotification;
  45.         }
  46.        
  47.         #endif
  48.        
  49.         public void OnSetLocalNotification()
  50.         {
  51.                 //Does nothing atm
  52.         }
  53.        
  54.         //Fires when returning from suspended and responded to localnotification
  55.         public void OnLocalNotificationFired(string id)
  56.         {
  57.                 switch(id)
  58.                 {
  59.                         case "MP01":    SetMPPanelOptions();
  60.                         break;
  61.  
  62.                         case "MP02":    SetMPPanelOptions();
  63.                         break;
  64.                                
  65.                         case "WMoment": SetWMPanelOptions();
  66.                         break;
  67.                 }
  68.         }
  69.        
  70.         public void WMBack()
  71.         {
  72.                 activePanel.SetActive(true);
  73.                 TweenPosition.Begin(PanelWidgets[23], settings.SpeedOfTweens, panelVector);
  74.                 TweenPosition.Begin(activePanel, settings.SpeedOfTweens, Vector3.zero).onFinished.Add(WMEvi);
  75.  
  76.         }
  77.  
  78.         private void SetMPPanelOptions()
  79.         {
  80.                 activePanel = CheckActive();
  81.  
  82.                 if(activePanel != null)
  83.                 {
  84.                         MotivButtons[0].gameObject.SetActive(false);
  85.                         MotivButtons[1].gameObject.SetActive(false);
  86.  
  87.                         PanelWidgets[4].SetActive(true);
  88.  
  89.                 }
  90.         }
  91.  
  92.         private void SetWMPanelOptions()
  93.         {
  94.                 activePanel = CheckActive();
  95.  
  96.                 if(activePanel != null)
  97.                 {
  98.                         WMButtons[0].gameObject.SetActive(false);
  99.                         WMButtons[1].gameObject.SetActive(true);
  100.  
  101.                         DEM.GetWeightMoment();
  102.  
  103.                         PanelWidgets[23].SetActive(true);
  104.                         TweenPosition.Begin(activePanel, 0, -panelVector);
  105.                         TweenPosition.Begin(PanelWidgets[23], 0, Vector3.zero).onFinished.Add(evi);
  106.  
  107.                 }
  108.                 else
  109.                 {
  110.                         Debug.Log ("ActivePanel = null :(");
  111.                 }
  112.         }
  113.  
  114.         private GameObject CheckActive()
  115.         {
  116.                 foreach(GameObject obj in PanelWidgets)
  117.                 {
  118.                         if(obj.activeSelf)
  119.                         {
  120.                                 return obj;
  121.                                 break;
  122.                         }
  123.                 }
  124.  
  125.                 return null;
  126.         }
  127.  
  128.  
  129.         private void TurnOff()
  130.         {
  131.                 activePanel.gameObject.SetActive(false);
  132.         }
  133.  
  134.         private void TurnOffWM()
  135.         {
  136.                 WMButtons[1].gameObject.SetActive(false);
  137.                 WMButtons[0].gameObject.SetActive(true);
  138.                 PanelWidgets[23].gameObject.SetActive(false);
  139.  
  140.         }
  141.  
  142. }
  143.  
  144.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Pulling widgets forward through script
« Reply #1 on: June 18, 2014, 04:26:59 PM »
Whatever LocalNotifications is, it really doesn't tell me much... Also please update to the latest version.

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Re: Pulling widgets forward through script
« Reply #2 on: June 18, 2014, 05:18:23 PM »
Whatever LocalNotifications is, it really doesn't tell me much... Also please update to the latest version.

I'm sorry about that I should have explained it more. I'm taling about Local Notifications on iOS. So when the app is suspended the user can still get messages about something happening in the app or something the user should do.
Also I can't upgrade to the latest version because that screws up my GUI, and since i'm in the last phase of development it's not possible to switch to the latest version.

EDIT:

I did found out that is has something to do with the OnFinished actions performed after the tweens. I'll look at it again tomorrow, maybe it's some error I made.