Exemplo n.º 1
0
        protected override void OnInit(object userData)
        {
            base.OnInit(userData);
            luaEnv = LuaManager.luaEnv; //此处要从LuaManager上获取 全局只有一个
            if (luaEnv == null)
            {
                return;
            }

            string prefabName = name;

            if (prefabName.Contains("(Clone)"))
            {
                prefabName = prefabName.Split(new string[] { "(Clone)" }, StringSplitOptions.RemoveEmptyEntries)[0] + "View";
            }
            //根据这个ui面板的名字监听 注意预制件上的名称要和lua脚本名称一致
            onInit        = luaEnv.Global.GetInPath <OnInitHandler>(prefabName + ".OnInit");
            onOnpe        = luaEnv.Global.GetInPath <OnOpenHandler>(prefabName + ".OnOpen");
            onClose       = luaEnv.Global.GetInPath <OnCloseHandler>(prefabName + ".OnClose");
            onBeforDestry = luaEnv.Global.GetInPath <OnBeforDestryHandler>(prefabName + ".OnBeforDestry");

            if (onInit != null)
            {
                onInit(transform, userData);
            }
        }
Exemplo n.º 2
0
        protected override void OnInit(object userData)
        {
            base.OnInit(userData);

            luaEnv = LuaManager.luaEnv; //此处要从LuaManager上获取 全局只有一个

            scriptEnv = luaEnv.NewTable();

            LuaTable meta = luaEnv.NewTable();

            meta.Set("__index", luaEnv.Global);
            scriptEnv.SetMetaTable(meta);
            meta.Dispose();

            string prefabName = name;

            if (prefabName.Contains("(Clone)"))
            {
                prefabName = prefabName.Split(new string[] { "(Clone)" }, StringSplitOptions.RemoveEmptyEntries)[0] + "View";
            }

            onInit         = scriptEnv.GetInPath <OnInitHandler>(prefabName + ".OnInit");
            onOpen         = scriptEnv.GetInPath <OnOpenHandler>(prefabName + ".OnOpen");
            onClose        = scriptEnv.GetInPath <OnCloseHandler>(prefabName + ".OnClose");
            onBeforDestroy = scriptEnv.GetInPath <OnBeforDestroyHandler>(prefabName + ".OnBeforDestroy");

            scriptEnv.Set("self", this);
            if (onInit != null)
            {
                onInit(userData);
            }
        }
Exemplo n.º 3
0
        protected override void OnInit()
        {
            base.OnInit();

            luaEnv = LuaManager.luaEnv;//从LuaManager上获取 全局只有一个
            if (luaEnv == null)
            {
                return;
            }

            scriptEnv = luaEnv.NewTable();

            LuaTable meta = luaEnv.NewTable();

            meta.Set("__index", luaEnv.Global);
            scriptEnv.SetMetaTable(meta);
            meta.Dispose();

            string name = "UI_TaskView";

            onInit   = scriptEnv.GetInPath <OnInitHandler>(name + ".OnInit");
            onOpen   = scriptEnv.GetInPath <OnOpenHandler>(name + ".OnOpen");
            onClose  = scriptEnv.GetInPath <OnCloseHandler>(name + ".OnClose");
            onBefore = scriptEnv.GetInPath <OnBeforeHandler>(name + ".OnBefore");
            scriptEnv.Set("self", this);
            onInit?.Invoke(UIFormTransform, Close);
        }
Exemplo n.º 4
0
        public static void WsRemoveOnOpen(uint objectId, OnOpenHandler callback)
        {
            if (!JslibInterop.onOpenHandlers.ContainsKey(objectId))
            {
                return;
            }

            JslibInterop.onOpenHandlers[objectId] -= callback;
        }
Exemplo n.º 5
0
        public static void WsAddOnOpen(uint objectId, OnOpenHandler callback)
        {
            if (!JslibInterop.onOpenHandlers.ContainsKey(objectId))
            {
                JslibInterop.onOpenHandlers[objectId] = null;
            }

            JslibInterop.onOpenHandlers[objectId] += callback;
        }
Exemplo n.º 6
0
        protected override void OnBeforeDestroy()
        {
            base.OnBeforeDestroy();
            onBefore?.Invoke();

            onInit   = null;
            onOpen   = null;
            onClose  = null;
            onBefore = null;
        }
Exemplo n.º 7
0
 protected override void OnBeforDestroy()
 {
     base.OnBeforDestroy();
     //备注 调用销毁的话,经常会造成Unity崩溃
     if (onBeforDestroy != null)
     {
         onBeforDestroy();
     }
     onInit         = null;
     onOpen         = null;
     onClose        = null;
     onBeforDestroy = null;
 }
Exemplo n.º 8
0
        protected override void OnBeforDestroy()
        {
            base.OnBeforDestroy();
            if (onBeforDestroy != null)
            {
                onBeforDestroy();
            }

            onInit         = null;
            onOpen         = null;
            onClose        = null;
            onBeforDestroy = null;

            int len = m_LuaComs.Length;

            for (int i = 0; i < len; i++)
            {
                LuaCom com = m_LuaComs[i];
                com.Trans = null;
                com       = null;
            }
            //卸载图片资源
            // int len = m_LuaComs.Length;
            // for (int i = 0; i < len; i++)
            // {
            //     LuaCom com = m_LuaComs[i];
            //
            //     switch (com.Type)
            //     {
            //         case LuaComType.Button:
            //         case LuaComType.Image:
            //         case LuaComType.YouYouImage:
            //             {
            //                 Image img = com.Trans.GetComponent<Image>();
            //                 img.sprite = null;
            //             }
            //             break;
            //         case LuaComType.RawImage:
            //             {
            //                 RawImage img = com.Trans.GetComponent<RawImage>();
            //                 img.texture = null;
            //             }
            //             break;
            //     }
            //
            //     com.Trans = null;
            //     com = null;
            // }
        }
        protected override void OnBeforeDestroy()
        {
            base.OnBeforeDestroy();
            if (onBeforeDestroy != null)
            {
                onBeforeDestroy();
            }
            onInit          = null;
            onOpen          = null;
            onClose         = null;
            onBeforeDestroy = null;

            //卸载图片资源
            int len = m_LuaComs.Length;

            for (int i = 0; i < len; i++)
            {
                LuaCom com = m_LuaComs[i];

                switch (com.Type)
                {
                case LuaComponentType.Button:
                case LuaComponentType.Image:
                case LuaComponentType.YouYouImage:
                {
                    Image ima = com.Trans.GetComponent <Image>();
                    ima.sprite = null;
                }
                break;

                case LuaComponentType.RawImage:
                {
                    RawImage ima = com.Trans.GetComponent <RawImage>();
                    ima.texture = null;
                }
                break;
                }
                com.Trans = null;
                com       = null;
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 删除
        /// </summary>
        protected override void OnBeforDestry()
        {
            base.OnBeforDestry();
            if (onBeforDestry != null)
            {
                onBeforDestry();
            }
            onInit        = null;
            onOnpe        = null;
            onClose       = null;
            onBeforDestry = null;

            //卸载图片资源
            int len = m_LuaComs.Length;

            for (int i = 0; i < len; i++)
            {
                LuaCom com = m_LuaComs[i];
                com.Trans = null;
                com       = null;
            }
        }
Exemplo n.º 11
0
        protected override void OnInit(object userData)
        {
            base.OnInit(userData);

            luaEnv = LuaManager.luaEnv; //此处要从LuaManager上获取 全局只有一个

            scriptEnv = luaEnv.NewTable();

            LuaTable meta = luaEnv.NewTable();

            meta.Set("__index", luaEnv.Global);
            scriptEnv.SetMetaTable(meta);
            meta.Dispose();

            string prefabName = name;

            if (prefabName.Contains("(Clone)"))
            {
                prefabName = prefabName.Split(new string[] { "(Clone)" }, StringSplitOptions.RemoveEmptyEntries)[0] + "View";
            }

            onInit          = scriptEnv.GetInPath <OnInitHandler>(prefabName + ".OnInit");
            onOpen          = scriptEnv.GetInPath <OnOpenHandler>(prefabName + ".OnOpen");
            onClose         = scriptEnv.GetInPath <OnCloseHandler>(prefabName + ".OnClose");
            onBeforeDestroy = scriptEnv.GetInPath <OnBeforeDestroyHandler>(prefabName + ".OnBeforeDestroy");

            scriptEnv.Set("self", this);
            //LuaTable t = LuaManager.ReturnNewTable("UI_TaskView");
            //Debug.Log(t == null);
            //t.Set("name", this.gameObject.name);

            //LuaTable model = luaEnv.Global.GetInPath<LuaTable>("UI_TaskView");
            //LuaTable t = luaEnv.NewTable();
            //t.SetMetaTable(model);
            ////model.Dispose();
            //t.Set("name", this.gameObject.name);


            LuaTable tmodel = luaEnv.Global.GetInPath <LuaTable>(prefabName);

            tmodel.Set("__index", tmodel);

            t = luaEnv.NewTable();
            t.SetMetaTable(tmodel);

            t.Set("name", this.gameObject.name);

            ta = t.GetInPath <TableFunc>("PrintName");
            ta(t);

            //ta = t.GetInPath<TableFunc>("UI_TaskView" + ".PrintName");
            //Debug.Log(ta == null);
            //if (ta == null)
            //{
            //    onClose = t.GetInPath<OnCloseHandler>("UI_TaskView" + ".Pme");
            //    Debug.Log("onClose");
            //    Debug.Log(onClose == null);
            //    OnClose();
            //}
            //ta(t);


            if (onInit != null)
            {
                onInit(transform, userData);
            }
        }