starwing / lua-protobuf

A Lua module to work with Google protobuf
MIT License
1.75k stars 387 forks source link

安卓手机上用Pb.loadfile 问题 #59

Closed hina90 closed 6 years ago

hina90 commented 6 years ago

在PC上使用Pb.loadfile注册PB文件的时候是正常可行的返回true,但是打包到安卓上注册pb文件的时候就注册不了了 返回nil, 文件夹下是有对应的pb文件的,还有其他什么原因会导致注册不成功吗?

hina90 commented 6 years ago

--初始化pb协议文件并注册 local function init_pb() local dataPath = CS.UnityEngine.Application.streamingAssetsPath; local pb_name = { dataPath.."/leo/pbc_struct/common.pb", dataPath.."/leo/pbc_struct/coreBattle.pb", dataPath.."/leo/pbc_struct/ResSkillAction.pb", dataPath.."/leo/pbc_struct/ResSkill.pb", dataPath.."/leo/pbc_struct/csMsg.pb", dataPath.."/leo/pbc_struct/ResBuff.pb", dataPath.."/leo/pbc_struct/ResFactor.pb", dataPath.."/leo/pbc_struct/ResLocalization.pb", } local function register_pb(name) local err = protobuf.loadfile(name); print("register url:"..name); print(err) end for i = 1, #pb_name do register_pb(pb_name[i]); end

我是通过这样注册PB的。

starwing commented 6 years ago

你不能用loadfile,安卓手机上无法使用stdio,你需要自己实现文件读取功能然后用pb.load()

starwing commented 6 years ago

关闭了,如果还有问题可以留言并重新打开~