Esempio n. 1
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. 2
0
        private static HS_LuaBehaviour Get(string uiName, out View view, out int index)
        {
            HS_LuaBehaviour t = null;

            view  = null;
            index = 0;
            for (int i = mViews.Count - 1; i >= 0; i--)
            {
                View obj = mViews[i];
                if (obj.view.GetViewPrefabName() == uiName)
                {
                    view  = obj;
                    index = i;
                    t     = obj.view as HS_LuaBehaviour;
                    break;
                }
            }
            return(t);
        }