Ejemplo n.º 1
0
        public void InitBehaviour()
        {
            if (!isInited)
            {
                isInited = true;

                if (ctrParamValues.Count == 0)
                {
                    Table = LuaUtility.RequireAndInstance(Env, scriptPath);
                }
                else
                {
                    SystemObject[] arr = new SystemObject[ctrParamValues.Count];
                    for (int i = 0; i < ctrParamValues.Count; ++i)
                    {
                        LuaParamValue lpv = ctrParamValues[i];
                        if (lpv != null)
                        {
                            arr[i] = lpv.GetValue();
                        }
                    }

                    Table = LuaUtility.RequireAndInstanceWith(Env, scriptPath, arr);
                }

                OnInitFinished();
            }
        }
Ejemplo n.º 2
0
        public void DoStart()
        {
            if (IsValid)
            {
                Debug.LogError("The bridge has been startup");
                return;
            }
            Env = new LuaEnv();
            Env.AddLoader(LuaScriptLoader.LoadScriptFromProject);
#if DEBUG
            Global.Set("isDebug", true);
#endif
            Env.AddBuildin("rapidjson", XLua.LuaDLL.Lua.LoadRapidJson);
            Global.Set("isRapidJson", true);
            Env.AddBuildin("pb", XLua.LuaDLL.Lua.LoadLuaProfobuf);

            gameTable          = LuaUtility.RequireAndGet(Env, initScriptPath);
            updateHandler      = gameTable.Get <Action <float, float> >(LuaUtility.UPDATE_FUNCTION_NAME);
            lateUpdateHandler  = gameTable.Get <Action <float, float> >(LuaUtility.UPDATE_FUNCTION_NAME);
            fixedUpdateHandler = gameTable.Get <Action <float, float> >(LuaUtility.FIXEDUPDATE_FUNCTION_NAME);

            Action startAction = gameTable.Get <Action>(LuaUtility.START_FUNCTION_NAME);
            startAction?.Invoke();
        }
Ejemplo n.º 3
0
 protected override string GetFilePath(string scriptPath)
 {
     return(LuaUtility.GetScriptFilePathInProject(scriptPath));
 }