Ejemplo n.º 1
0
        /// <summary>
        /// 调用Lua:OnOpen函数
        /// </summary>
        /// <param name="args"></param>
        public override void OnOpen(params object[] args)
        {
            // 编辑器模式下,记录
            LastOnOpenArgs = args;

            base.OnOpen(args);
            if (!CheckInitScript())
            {
                CSUIController csController = this.gameObject.GetComponent <CSUIController>();
                if (csController)
                {
                    csController.OnOpen(args);
                }
                return;
            }

            var onOpenFuncObj = _luaTable.Get <LuaFunction>("OnOpen");

            if (onOpenFuncObj == null)
            {
                Log.LogError("Not Exists `OnOpen` in lua: {0}", UITemplateName);
                return;
            }

            var newArgs = new object[args.Length + 1];

            newArgs[0] = _luaTable;
            for (var i = 0; i < args.Length; i++)
            {
                newArgs[i + 1] = args[i];
            }

            (onOpenFuncObj as LuaFunction).Call(newArgs);
        }
Ejemplo n.º 2
0
        public override void OnInit()
        {
            base.OnInit();

            if (!CheckInitScript(true))
            {
                CSUIController csController = this.gameObject.GetComponent <CSUIController>();
                if (csController)
                {
                    csController.OnInit();
                }
                return;
            }
        }
Ejemplo n.º 3
0
        public override void OnClose()
        {
            base.OnClose();
            if (!CheckInitScript())
            {
                CSUIController csController = this.gameObject.GetComponent <CSUIController>();
                if (csController)
                {
                    csController.OnClose();
                }
                return;
            }
            var closeFunc = _luaTable["OnClose"];

            if (closeFunc != null)
            {
                (closeFunc as LuaFunction).Call(_luaTable);
            }
        }