UnityLua运行时GM

local params = string.split(str,"@")
if params[1] == "clientGlobal" then
		_G[tostring(params[2])](params[3],params[4],params[5])
elseif params[1] == "clientLocal" then
		_G[tostring(params[2])][params[3]](_G[tostring(params[2])],params[4],params[5],params[6])
elseif params[1] == "PanelMgr" then
		PanelMgr:SendMsg(params[2],params[3],params[4],params[5])
    end
clientGlobal@方法名@参数
clientLocal@脚本名@方法名@参数
PanelMgr@脚本名@方法名@参数--[[
--[[

if params[1] == "_G" then
		local finFun = string.split(string.sub(str,4),"&")
		local script = _G
		local funLua 
		local beforeFun = string.split(finFun[1],"@")
		local AfterFun = string.split(finFun[2],"@")
		for i, v in ipairs(beforeFun) do
			if i == #beforeFun then
				funLua = script[v]
			else
				script =	script[v]
			end
		end
		if script == _G then
			funLua(AfterFun[1],AfterFun[2],AfterFun[3])
		else
			funLua(script,AfterFun[1],AfterFun[2],AfterFun[3])
		end
    end

clientGlobal@方法名@参数
clientLocal@脚本名@方法名@参数
PanelMgr@脚本名@方法名@参数
_G@...@方法名&参数...


案例
clientGlobal@print@参数
clientLocal@GalaxyMgr@PrintAAAA@参数
PanelMgr@TechTreePanel@SetGroupIdTxtState@true
_G@GalaxyMgr@PrintAAAA&参数
]]
]]

猜你喜欢

转载自blog.csdn.net/weixin_41995872/article/details/128290076