Beispiel #1
0
        public static int SetParent(int parent, int child, bool reset)
        {
            Transform ptrans = GetTransform(parent);

            if (!ptrans)
            {
                return(-1);
            }

            Transform ctrans = GetTransform(child);

            if (!ctrans)
            {
                return(-2);
            }

            ctrans.parent = ptrans;

            if (reset)
            {
                GameCommon.ResetTrans(ctrans);
            }

            return(0);
        }
Beispiel #2
0
        public static void ResetTrans(int id)
        {
            Transform trans = GetTransform(id);

            if (!trans)
            {
                return;
            }

            GameCommon.ResetTrans(trans);
        }
Beispiel #3
0
        private void Create()
        {
            status = UIStatus.Creating;
            ResLoader.LoadByName(name, (asset, param) =>
            {
                if (asset == null)
                {
                    return;
                }
                GameObject goo = ((GameObject)Object.Instantiate(asset));
                goo.name       = name;
                uiData         = goo.GetComponent <UIData>();
                if (uiData == null)
                {
                    Debugger.LogError("ui prefab has no UIData->" + name);
                    return;
                }

                for (int i = 0, count = uiData.events.Count; i < count; i++)
                {
                    RegisterEvent(uiData.events[i]);
                }

                for (int i = 0, count = uiData.labels.Count; i < count; i++)
                {
                    uiData.labels[i].label.font = comFont;
                }

                m_transform        = uiData.transform;
                m_transform.parent = UIManager.GetUIRoot();

                GameCommon.ResetTrans(m_transform);
                UIPanel[] panels = m_transform.GetComponents <UIPanel>();
                if (panels.Length > 0)
                {
                    uiData.panels.AddRange(panels);
                }
                panels = m_transform.GetComponentsInChildren <UIPanel>();
                if (panels.Length > 0)
                {
                    uiData.panels.AddRange(panels);
                }

                if (layer >= 0)
                {
                    UIPanel panel = null;
                    for (int i = 0, count = uiData.panels.Count; i < count; i++)
                    {
                        panel = uiData.panels[i];
                        panel.sortingOrder = panel.depth;
                    }
                }

                UIManager.UICreateCall(id, this);


#if JSSCRIPT
                jsRepresentClass.CallFunctionByFunName("OnCreate", this);
#elif LUASCRIPT
                if (lua_OnCreate == null)
                {
                    lua_OnCreate = LuaManager.GetFunction(name + ".OnCreate");
                }
                if (lua_OnCreate != null)
                {
                    LuaManager.CallFunc_V(lua_OnCreate, this);
                }
#endif

                UIManager.RegisterUILayer(layer, this);

                if (hasBG)
                {
                    GameObject go    = new GameObject();
                    go.layer         = m_transform.gameObject.layer;
                    Transform strans = go.transform;
                    strans.parent    = m_transform;
                    GameCommon.ResetTrans(strans);
                    strans.localScale = new Vector3(2000, 2000, 1);
                    UIColorSprite ucs = go.AddComponent <UIColorSprite>();
                    ucs.depth         = -1;
                    ucs.SetShaderEnum(UIColorSprite.ShaderEnum.SH2, true);
                    ucs.SetColor(bgColor);

                    if (bgCollider)
                    {
                        go.AddComponent <BoxCollider>();
                    }
                }

                if (status != UIStatus.Creating)
                {
                    Debugger.Log("create show ui after disable");
                    ProcessShow(false);
                    ClearAtlas();
                    ClearTextures();
                    return;
                }

                Prepare();

                if (lua_OnShowOver == null)
                {
                    lua_OnShowOver = LuaManager.GetFunction(name + ".OnShowOver");
                }
                if (lua_OnShowOver != null)
                {
                    LuaManager.CallFunc_V(lua_OnShowOver, this);
                }
            }, null);
        }