Esempio n. 1
0
        private static void Close(View view, int index)
        {
            System.Action closeAction = delegate {
                mViews.RemoveAt(index);
                HS_ViewBase.InternalClosed(view.view);
                GameObject.Destroy(view.view.gameObject);

                if (view.view is IForwardModalles)
                {
                    bool found = false;
                    for (int i = mViews.Count - 1; i >= 0; i--)
                    {
                        if (mViews[i].view is IForwardModalles)
                        {
                            mTagMask.transform.SetAsLastSibling();
                            mViews[i].view.transform.SetAsLastSibling();
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        mTagMask.transform.localScale = Vector3.zero;
                    }
                }
            };
            closeAction();
        }
Esempio n. 2
0
        public static HS_LuaBehaviour Open(string uiPrefabName, LuaTable luaTable)
        {
            if (mRoot == null)
            {
                Debugger.LogError("Have No UI root gameObject.");
                return(null);
            }

            View            view;
            int             index;
            HS_LuaBehaviour t = Get(uiPrefabName, out view, out index);

            if (t == null)
            {
                GameObject srcGo = HS_ResourceManager.LoadAsset <GameObject>(uiPrefabName);
                //GameObject go = GameObject.Instantiate(srcGo);

                bool b = luaTable.RawGet <string, bool>("IForward");

                GameObject go = UIAddChild(b ? mTagForward : mTagNormal, srcGo);
                t = go.AddComponent <HS_LuaBehaviour>();
                t.Attach(luaTable);

                view = new View(t);
                mViews.Add(view);
                HS_ViewBase.InternalOpened(view.view);
            }
            GameObject rootCanvas = (t is IForward) ? mTagForward : mTagNormal;

            view.view.transform.SetSiblingIndex(rootCanvas.transform.childCount - 1);

            if (t is IForwardModalles)
            {
                mMaskHolder++;

                mTagMask.transform.SetSiblingIndex(view.view.transform.GetSiblingIndex() - 1);
                mTagMask.GetComponent <Image>().color = defaultMaskColor;
                mTagMask.transform.localScale         = Vector3.one;
                (t as IForwardModalles).CustomMask(mTagMask.transform);

                mTagMask.GetComponent <Button>().onClick.AddListener(delegate
                {
                    (t as IForwardModalles).MaskClickHandle();
                });
            }

            return(t);
        }
Esempio n. 3
0
 public static void Close(HS_ViewBase view)
 {
     if (view == null)
     {
         return;
     }
     for (int i = mViews.Count - 1; i >= 0; i--)
     {
         View obj = mViews[i];
         if (obj.view == view)
         {
             Close(obj, i);
             break;
         }
     }
 }
Esempio n. 4
0
        public static T Open <T>() where T : HS_ViewBase
        {
            if (mRoot == null)
            {
                Debug.LogError("Have No UI root gameObject.");
                return(null);
            }


            View view;
            int  index;
            T    t = Get <T>(out view, out index);

            if (t == null)
            {
                T          temp   = mRoot.AddComponent <T>();
                GameObject prefab = temp.GetViewPrefab();
                GameObject go     = UIAddChild((temp is IForward) ? mTagForward : mTagNormal, prefab);
                GameObject.Destroy(temp);

                t    = go.AddComponent <T>();
                view = new View(t);
                mViews.Add(view);
                HS_ViewBase.InternalOpened(view.view);
            }
            GameObject rootCanvas = (t is IForward) ? mTagForward : mTagNormal;

            view.view.transform.SetSiblingIndex(rootCanvas.transform.childCount - 1);

            if (t is IForwardModalles)
            {
                mMaskHolder++;

                mTagMask.transform.SetSiblingIndex(view.view.transform.GetSiblingIndex() - 1);
                mTagMask.GetComponent <Image>().color = defaultMaskColor;
                mTagMask.transform.localScale         = Vector3.one;
                (t as IForwardModalles).CustomMask(mTagMask.transform);

                mTagMask.GetComponent <Button>().onClick.AddListener(delegate
                {
                    (t as IForwardModalles).MaskClickHandle();
                });
            }

            return(t);
        }
Esempio n. 5
0
 public static void BringToDown(HS_ViewBase view)
 {
     //GameObject rootCanvas = (view is IForward) ? mTagForward : mTagNormal;
     view.transform.SetSiblingIndex(0);
 }
Esempio n. 6
0
        public static void BringToTop(HS_ViewBase view)
        {
            GameObject rootCanvas = (view is IForward) ? mTagForward : mTagNormal;

            view.transform.SetSiblingIndex(rootCanvas.transform.childCount - 1);
        }
Esempio n. 7
0
 public View(HS_ViewBase _view)
 {
     this.view = _view;
 }