Xlua开发中需要注意到的坑~

----给c#中的委托赋值
function OnSyncOutlimitDataNotify( msg )
local reply = CS.ProtoBuf.Serializer.Deserialize(msg.data, typeof(CS.Module.SyncOutlimitDataNotify));
end
CS.Module.ModUser.Instance.OnSyncOutlimitDataNotify = OnSyncOutlimitDataNotify;
结束后,需要手动置空:CS.Module.ModUser.Instance.OnSyncOutlimitDataNotify = nil
-- “非”的使用方式
if not IsNilOrNull(self._rewardElement) then
end
---获取重载方法
local csgettype = typeof(CS.System.Type):GetMethod('GetType', {typeof(CS.System.String)})
local luagettype = xlua.tofunction(csgettype)
local raycasthittype = luagettype("UnityEngine.RaycastHit&, UnityEngine")
---获取组件
local tableWidght = self._picTable:GetComponent("UIWidget");
或者 local mec = lottoItemGo.transform:GetComponent(typeof(CS.MusicEnergyItemCell));
---int转枚举类型
CS.GAME_REWARD_TYPE.__CastFrom(self._packProtype._costItemType)
---在当前类中开启对另外一个类的私有成员变量的访问权限(在YIMMgr中访问DlgChat的私有成员eChannel)
xlua.private_accessible( CS.YIMMgr ); -- 开启私有成员访问权限
xlua.private_accessible( CS.DlgChat ) -- 开启私有成员访问权限
local dlgChat = CS.DlgMgr.Instance:GetDlg("DlgChat")
if (dlgChat._eChannel == CS.EnumChatChannel.WORLD)
---实例化一个对象
CS.UnityEngine.Vector3(1400, 800, 0)
---判断是否是某个类的对象
CS.GameStateMachine.Instance.current:GetType() == typeof(CS.LobbyState)

你可能感兴趣的:(Lua)