示例#1
0
            private void OnLoaded(GameObject go)
            {
                if (!mActive)
                {
                    mUILoader.UnloadInstance(go);
                    return;
                }
                gameObject = go;
                RectTransform rectTrans = go.transform as RectTransform;

                rectTrans.SetParent(popup_root, false);
                rectTrans.offsetMin     = Vector2.zero;
                rectTrans.offsetMax     = Vector2.zero;
                rectTrans.localRotation = Quaternion.identity;
                rectTrans.localScale    = Vector3.one;
                bool overlay = false;

                mBehaviours.Clear();
                go.GetComponents <MonoBehaviour>(mBehaviours);
                bool paraSet = false;

                for (int i = 0, imax = mBehaviours.Count; i < imax; i++)
                {
                    MonoBehaviour       behaviour = mBehaviours[i];
                    IUIParameterHandler handler   = behaviour as IUIParameterHandler;
                    if (handler != null)
                    {
                        try { handler.SetParameter(param); } catch (System.Exception e) { Debug.LogError(e); }
                        paraSet = true;
                    }
                    IPopupOverlay popupOverlay = behaviour as IPopupOverlay;
                    if (popupOverlay != null && popupOverlay.Overlay)
                    {
                        overlay = true;
                    }
                }
                if (param != null && !paraSet)
                {
                    Debug.LogErrorFormat(go, "[UIManager] No parameter handler found for '{0]' !", name);
                }
                if (mFocusState == 1)
                {
                    for (int i = 0, imax = mBehaviours.Count; i < imax; i++)
                    {
                        IUIFocusHandler handler = mBehaviours[i] as IUIFocusHandler;
                        if (handler != null)
                        {
                            try { handler.OnFocus(); } catch (System.Exception e) { Debug.LogException(e); }
                        }
                    }
                    mFocusState = 2;
                }
                go.SetActive(visible);
                LoadedCallback callback = mOnLoadedCallback;

                mOnLoadedCallback = null;
                callback(this, overlay);
            }
示例#2
0
            private void OnLoaded(GameObject go)
            {
                System.Action callback = mOnLoadedCallback;
                if (callback != null)
                {
                    try { callback(); } catch (System.Exception e) { Debug.LogException(e); }
                }
                if (!mActive)
                {
                    mUILoader.UnloadInstance(go);
                    return;
                }
                mGameObject = go;
                RectTransform rectTrans = go.transform as RectTransform;

                rectTrans.SetParent(window_root, false);
                rectTrans.offsetMin     = Vector2.zero;
                rectTrans.offsetMax     = Vector2.zero;
                rectTrans.localRotation = Quaternion.identity;
                rectTrans.localScale    = Vector3.one;
                mBehaviours.Clear();
                go.GetComponents <MonoBehaviour>(mBehaviours);
                bool paraSet = false;

                for (int i = 0, imax = mBehaviours.Count; i < imax; i++)
                {
                    IUIParameterHandler handler = mBehaviours[i] as IUIParameterHandler;
                    if (handler != null)
                    {
                        try { handler.SetParameter(param); } catch (System.Exception e) { Debug.LogError(e); }
                        paraSet = true;
                    }
                }
                if (param != null && !paraSet)
                {
                    Debug.LogErrorFormat(go, "[UIManager] No parameter handler found for '{0]' !", name);
                }
                if (mFocusState == 1)
                {
                    for (int i = 0, imax = mBehaviours.Count; i < imax; i++)
                    {
                        IUIFocusHandler handler = mBehaviours[i] as IUIFocusHandler;
                        if (handler != null)
                        {
                            try { handler.OnFocus(); } catch (System.Exception e) { Debug.LogException(e); }
                        }
                    }
                    mFocusState = 2;
                }
                if (on_end_load_window != null)
                {
                    on_end_load_window();
                }
            }
示例#3
0
 public void LoseFocus()
 {
     if (gameObject != null)
     {
         for (int i = 0, imax = mBehaviours.Count; i < imax; i++)
         {
             IUIFocusHandler handler = mBehaviours[i] as IUIFocusHandler;
             if (handler != null)
             {
                 try { handler.OnLoseFocus(); } catch (System.Exception e) { Debug.LogException(e); }
             }
         }
     }
     mFocusState = 0;
 }
示例#4
0
 public void Close()
 {
     mActive = false;
     if (mGameObject != null)
     {
         for (int i = 0, imax = mBehaviours.Count; i < imax; i++)
         {
             IUIFocusHandler handler = mBehaviours[i] as IUIFocusHandler;
             if (handler != null)
             {
                 try { handler.OnClose(); } catch (System.Exception e) { Debug.LogException(e); }
             }
         }
         mUILoader.UnloadInstance(mGameObject);
         mGameObject = null;
         mBehaviours.Clear();
     }
 }
示例#5
0
 public void Close(bool anim)
 {
     if (gameObject != null)
     {
         mClosing = true;
         for (int i = 0, imax = mBehaviours.Count; i < imax; i++)
         {
             MonoBehaviour   behaviour    = mBehaviours[i];
             IUIFocusHandler focusHandler = behaviour as IUIFocusHandler;
             if (focusHandler != null)
             {
                 try { focusHandler.OnClose(); } catch (System.Exception e) { Debug.LogException(e); }
             }
             if (anim)
             {
                 IPopupCloseAnim closeAnim = behaviour as IPopupCloseAnim;
                 if (closeAnim != null)
                 {
                     mClosingCount++;
                     closeAnim.ExecuteClose(mOnCloseAnimCallback);
                 }
             }
         }
         mClosing = false;
     }
     System.Action callback = onClose;
     if (callback != null)
     {
         try { callback(); } catch (System.Exception e) { Debug.LogException(e); }
     }
     if (mClosingCount > 0)
     {
         // TODO block ui
     }
     else
     {
         ClearInstance();
     }
 }