コード例 #1
0
ファイル: HS_ViewManager.cs プロジェクト: qipa/HSFramework
        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);
        }
コード例 #2
0
ファイル: HS_ViewManager.cs プロジェクト: qipa/HSFramework
        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);
        }