Пример #1
0
        private void OnDisable()
        {
            if (uiData == null)
            {
                return;
            }
            UIManager.ResetUIAlpha(this);

            scriptShowUICall = null;
            UISpriteData data = null;

            for (int i = 0, count = uiData.sprites.Count; i < count; i++)
            {
                data = uiData.sprites[i];
                SetAtlas(data, false);
            }

#if JSSCRIPT
            jsRepresentClass.CallFunctionByFunName("OnDisable", this);
#elif LUASCRIPT
            if (lua_OnDisable == null)
            {
                lua_OnDisable = LuaManager.GetFunction(name + ".OnDisable");
            }
            if (lua_OnDisable != null)
            {
                LuaManager.CallFunc_V(lua_OnDisable, this);
            }
#endif
        }
Пример #2
0
        public static void Ping(string ip, LuaInterface.LuaFunction func, int funcID)
        {
            if (func == null)
            {
                return;
            }

            NetPing ping = GenPing();

            if (ping == null)
            {
                Debug.LogError("ping num is to much");
                return;
            }

            if (Config.Detail_Debug_Log())
            {
                Debug.Log("----------net ping 0->" + ip);
            }
            CoroutineHelper.CreateCoroutineHelper(ping.PingConnect(ip, (state, delay) =>
            {
                ping.index = -1;
                LuaManager.CallFunc_V(func, state, delay, funcID);
            }));
        }
Пример #3
0
        private static IEnumerator HttpGet(string url, bool strResult, LuaInterface.LuaFunction func)
        {
            WWW www = new WWW(url);

            yield return(www);

            if (www.error != null)
            {
                Debugger.LogError("n http get send error->" + www.error);
            }
            else
            {
                if (www.bytes != null)
                {
                    if (strResult)
                    {
                        string data = System.Text.Encoding.UTF8.GetString(www.bytes);
                        Debug.LogError("http get re->" + data);
                        LuaManager.CallFunc_V(func, data);
                    }
                    else
                    {
                        LuaManager.CallFunc_V(func, www.bytes);
                    }
                }
            }

            www.Dispose();
        }
Пример #4
0
 private static void CallLuaRecvFunc(NetAdapter.DeserializeData data)
 {
     if (protoBufCall != null)
     {
         LuaManager.CallFunc_V(protoBufCall, data.data.get_tid(), data.data.get_gid(), data.data.get_uid(), data.data.get_data(), data.data.get_datalen());
     }
 }
Пример #5
0
 internal static void Common_UIOnClick(int uiID, int btnID)
 {
     if (uiOnClickCall != null)
     {
         LuaManager.CallFunc_V(uiOnClickCall, uiID, btnID);
     }
 }
Пример #6
0
 private void CallLuaRecvFunc(NetAdapter.DeserializeData data)
 {
     //Debugger.Log("recv msg call lua func->" + (recvMsgCall == null));
     if (recvMsgCall != null)
     {
         LuaManager.CallFunc_V(recvMsgCall, data.data.get_tid(), data.data.get_gid(), data.data.get_uid(), data.data.get_data(), data.data.get_datalen());
     }
     //Debugger.Log("recv msg call lua func 1");
 }
Пример #7
0
 private void CallLuaRecvFunc(NetAdapter.DeserializeData data)
 {
     if (Config.Detail_Debug_Log())
     {
         Debug.Log("recv server msg push to lua->" + data.data.get_tid() + "^" + data.data.get_gid() + "^" + data.data.get_uid() + "^" + data.data.get_datalen() + "^" + (recvMsgCall == null));
     }
     if (recvMsgCall != null)
     {
         LuaManager.CallFunc_V(recvMsgCall, data.data.get_tid(), data.data.get_gid(), data.data.get_uid(), data.data.get_data(), data.data.get_datalen());
     }
 }
Пример #8
0
 internal void OnMessageCallBack(string result)
 {
     if (lua_OnMessage == null)
     {
         lua_OnMessage = LuaManager.GetFunction("MessageBox.OnMessage");
     }
     if (lua_OnMessage != null)
     {
         LuaManager.CallFunc_V(lua_OnMessage, result);
     }
 }
Пример #9
0
 internal void OnDialogCallBack(string result)
 {
     if (lua_OnDialog == null)
     {
         lua_OnDialog = LuaManager.GetFunction("MessageBox.OnDialog");
     }
     if (lua_OnDialog != null)
     {
         LuaManager.CallFunc_V(lua_OnDialog, result);
     }
 }
Пример #10
0
        private void OnHover(GameObject gameObject, bool isOver, int id)
        {
            if (listenOnHover && !UIManager.IsFocusEventLocked(uiID, id))
            {
#if JSSCRIPT
                jsRepresentClass.CallFunctionByFunName("OnHover", gameObject, isOver, id);
#elif LUASCRIPT
                if (lua_OnHover == null)
                {
                    lua_OnHover = LuaManager.GetFunction(name + ".OnHover");
                }
                if (lua_OnHover != null)
                {
                    LuaManager.CallFunc_V(lua_OnHover, gameObject, id);
                }
#endif
            }
        }
Пример #11
0
        private void OnSelect(GameObject gameObject, bool selected, int id)
        {
            if (listenOnSelect && !UIManager.IsFocusEventLocked(uiID, id))
            {
#if JSSCRIPT
                jsRepresentClass.CallFunctionByFunName("OnSelect", gameObject, selected, id);
#elif LUASCRIPT
                if (lua_OnSelect == null)
                {
                    lua_OnSelect = LuaManager.GetFunction(name + ".OnSelect");
                }
                if (lua_OnSelect != null)
                {
                    LuaManager.CallFunc_V(lua_OnSelect, gameObject, selected, id);
                }
#endif
            }
        }
Пример #12
0
        private void OnScroll(GameObject gameObject, float delta, int id)
        {
            if (listenOnSroll && !UIManager.IsFocusEventLocked(uiID, id))
            {
#if JSSCRIPT
                jsRepresentClass.CallFunctionByFunName("OnScroll", gameObject, delta, id);
#elif LUASCRIPT
                if (lua_OnScroll == null)
                {
                    lua_OnScroll = LuaManager.GetFunction(name + ".OnScroll");
                }
                if (lua_OnScroll != null)
                {
                    LuaManager.CallFunc_V(lua_OnScroll, gameObject, delta, id);
                }
#endif
            }
        }
Пример #13
0
        private void OnDoubleClick(GameObject gameObject, int id)
        {
            if (listenOnDoubleClick && !UIManager.IsFocusEventLocked(uiID, id))
            {
#if JSSCRIPT
                jsRepresentClass.CallFunctionByFunName("OnDoubleClick", gameObject, id);
#elif LUASCRIPT
                if (lua_OnDoubleClick == null)
                {
                    lua_OnDoubleClick = LuaManager.GetFunction(name + ".OnDoubleClick");
                }
                if (lua_OnDoubleClick != null)
                {
                    LuaManager.CallFunc_V(lua_OnDoubleClick, gameObject, id);
                }
#endif
            }
        }
Пример #14
0
        private void OnDrag(GameObject gameObject, Vector2 delta, int id)
        {
            if (listenOnDrag && !UIManager.IsFocusEventLocked(uiID, id))
            {
#if JSSCRIPT
                jsRepresentClass.CallFunctionByFunName("OnDrag", gameObject, delta, id);
#elif LUASCRIPT
                if (lua_OnDrag == null)
                {
                    lua_OnDrag = LuaManager.GetFunction(name + ".OnDrag");
                }
                if (lua_OnDrag != null)
                {
                    LuaManager.CallFunc_V(lua_OnDrag, gameObject, delta, id);
                }
#endif
            }
        }
Пример #15
0
        private void OnTooltip(GameObject gameObject, bool show, int id)
        {
            if (listenOnTooltip && !UIManager.IsFocusEventLocked(uiID, id))
            {
#if JSSCRIPT
                jsRepresentClass.CallFunctionByFunName("OnTooltip", gameObject, show, id);
#elif LUASCRIPT
                if (lua_OnTooltip == null)
                {
                    lua_OnTooltip = LuaManager.GetFunction(name + ".OnTooltip");
                }
                if (lua_OnTooltip != null)
                {
                    LuaManager.CallFunc_V(lua_OnTooltip, gameObject, show, id);
                }
#endif
            }
        }
Пример #16
0
        private void OnKey(GameObject gameObject, KeyCode key, int id)
        {
            if (listenOnKey && !UIManager.IsFocusEventLocked(uiID, id))
            {
#if JSSCRIPT
                jsRepresentClass.CallFunctionByFunName("OnKey", gameObject, key, id);
#elif LUASCRIPT
                if (lua_OnKey == null)
                {
                    lua_OnKey = LuaManager.GetFunction(name + ".OnKey");
                }
                if (lua_OnKey != null)
                {
                    LuaManager.CallFunc_V(lua_OnKey, gameObject, key, id);
                }
#endif
            }
        }
Пример #17
0
        private void OnEnable()
        {
            if (uiData == null)
            {
                return;
            }

            if (lowLayerAlpha < 1)
            {
                UIManager.SetLessLayerUIAlpha(layer, lowLayerAlpha);
            }

            UIManager.ProcessUIAlpha(this);

            UISpriteData data = null;

            for (int i = 0, count = uiData.sprites.Count; i < count; i++)
            {
                data = uiData.sprites[i];
                SetAtlas(data, true);
            }

            UITextureData utd = null;

            for (int i = 0, count = uiData.textures.Count; i < count; i++)
            {
                utd = uiData.textures[i];
                SetTexture(utd, true);
            }

#if JSSCRIPT
            jsRepresentClass.CallFunctionByFunName("OnEnable", this);
#elif LUASCRIPT
            if (lua_OnEnable == null)
            {
                lua_OnEnable = LuaManager.GetFunction(name + ".OnEnable");
            }
            if (lua_OnEnable != null)
            {
                LuaManager.CallFunc_V(lua_OnEnable, this);
            }
#endif
        }
Пример #18
0
        private void LoadAssetOver()
        {
            if (uiData == null)
            {
                Create();
            }
            else
            {
                ProcessShow(true);
                Prepare();

                if (lua_OnShowOver == null)
                {
                    lua_OnShowOver = LuaManager.GetFunction(name + ".OnShowOver");
                }
                if (lua_OnShowOver != null)
                {
                    LuaManager.CallFunc_V(lua_OnShowOver, this);
                }
            }
        }
Пример #19
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);
        }