Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS Error,xLua exception : Framework.Updater.Coroutine:100: Net.Util.PBUtil:14 #3

Open
wangzhumo opened this issue Sep 15, 2022 · 0 comments

Comments

@wangzhumo
Copy link

Error Stack

xLua exception : Framework.Updater.Coroutine:100: Net.Util.PBUtil:14: attempt to call a nil value (field 'loadfile')
stack traceback:
	Net.Util.PBUtil:14: in local 'func'
	Common.TableUtil:126: in function 'table.walk'
	Net.Util.PBUtil:11: in method 'LoadPB'
	GameMain:10: in upvalue 'Initilize'
	GameMain:62: in local 'func'
	Framework.Updater.Coroutine:42: in function <Framework.Updater.Coroutine:39>
stack traceback:
	[C]: in function 'error'
	Framework.Logger.Logger:18: in field 'LogError'
	Framework.Updater.Coroutine:100: in upvalue '__PResume'
	Framework.Updater.Coroutine:115: in function 'coroutine.start'
	GameMain:61: in function 'GameMain.Start'
	[string "chunk"]:1: in main chunk
   at XLua.LuaEnv.ThrowExceptionFromError (System.Int32 oldTop) [0x00040] in /Users/wangzhumo/Workspace/UnitySpace/Nice-Lua-master/Assets/Scripts/XLua/Scripts/LuaEnv.cs:443 
  at XLua.LuaEnv.DoString (System.Byte[] chunk, System.String chunkName, XLua.LuaTable env) [0x00078] in /Users/wangzhumo/Workspace/UnitySpace/Nice-Lua-master/Assets/Scripts/XLua/Scripts/LuaEnv.cs:276 
  at XLua.LuaEnv.DoString (System.String chunk, System.String chunkName, XLua.LuaTable env) [0x0000d] in /Users/wangzhumo/Workspace/UnitySpace/Nice-Lua-master/Assets/Scripts/XLua/Scripts/LuaEnv.cs:290 
  at XLuaManager.SafeDoString (System.String scriptContent) [0x00010] in /Users/wangzhumo/Workspace/UnitySpace/Nice-Lua-master/Assets/Scripts/XLua/XLuaManager.cs:110 
UnityEngine.Debug:LogError (object)
Logger:LogError (string,object[]) (at Assets/Scripts/Common/Logger/Logger.cs:63)
XLuaManager:SafeDoString (string) (at Assets/Scripts/XLua/XLuaManager.cs:115)
XLuaManager:StartGame () (at Assets/Scripts/XLua/XLuaManager.cs:149)
AddressableUpdater/<StartGame>d__8:MoveNext () (at Assets/Scripts/GameLaunch/AddressableUpdater.cs:125)
UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr) (at /Users/bokken/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17)

原因

local PBUtil = BaseClass("PBUtil", Singleton)

-- 加载所有PB
local function LoadPB(self)
    local pbFiles = {
        "Net/PB/OuterMessage.pb",
    }
    print(CS.GameUtility.GetPlatform())    -- print   OSXEditor
    --编辑器下和移动端,加载位置不同
    if(CS.GameUtility.GetPlatform() == "WindowsEditor" or CS.GameUtility.GetPlatform() == "OSXEditor") then
        table.walk(pbFiles,function(i,path)
            print(pb)     -- print   0x000
            print(pb.loadfile)   -- print  nil
            assert(pb.loadfile("Assets/LuaScripts/"..path))
            print(path.." pb load success")
        end)
    else
        table.walk(pbFiles,function(i,path)
            ResourcesManager:GetInstance():LoadAsync(path..".bytes", typeof(CS.UnityEngine.TextAsset), function(data)
                print(path.." pb load addr success")
                assert(pb.load(data.bytes))
            end)
        end)
    end

end

PBUtil.LoadPB = LoadPB
return PBUtil

print(pb.loadfile) -- print nil

解决方法:

更换xlua.bundle即可

https://github.com/chexiongsheng/build_xlua_with_libs

  • 下载 https://github.com/chexiongsheng/build_xlua_with_libs/releases/tag/v2.1.15 解压Plugins覆盖项目Plugins/XLua
  • 使用 build_xlua_with_libs/build/make_osx_lua54.sh ,编译出 xlua.bundle 替换项目中的 xlua.bundle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant