Exemplo n.º 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);
            }
Exemplo n.º 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();
                }
            }