此代码由代理调用:
private void OnMsgBoxClick(object arg)
{
if (arg.GetType() == typeof(int))
{
this.LogWarning("OnMsgBoxClick() arg: {0}", arg.ToString());
}
}
它给出了NullReferenceException,但是像这样仍然调试了这句话:
NullReferenceException: Object reference not set to an instance of an object
> 21:29:11.777 Example_MsgBox::Invoke() OnMsgBoxClick() arg: 0
,并且我想获得没有错误的调试器。我该如何处理这个问题?
这是我的错误调用堆栈。
NullReferenceException: Object reference not set to an instance of an object
Example_MsgBox.OnMsgBoxClick (System.Object arg) (at Assets/GamePlay/Example/Example_MsgBox.cs:28)
GamePlay.UI.UIAPI+<ShowMsgBox>c__AnonStorey0.<>m__0 (System.Object closeArg) (at Assets/GamePlay/UI/UIAPI.cs:32)
SGF.UI.FrameWork.UIWindow.OnDisable () (at Assets/SGF/UI/FrameWork/UIWindow.cs:73)
UnityEngine.GameObject:SetActive(Boolean)
SGF.UI.FrameWork.UIWindow:Close(Object) (at Assets/SGF/UI/FrameWork/UIWindow.cs:119)
GamePlay.UI.Common.UIMsgBox:OnBtnClick(Int32) (at Assets/GamePlay/UI/Common/UIMsgBox.cs:62)
UnityEngine.EventSystems.EventSystem:Update()
这是'UIMsgBox':
public void OnBtnClick(int btnIndex)
{
if (btnIndex.GetType() == typeof(int))
{
this.Close(btnIndex);
}
}
这是'UIWindow':
public delegate void CloseEvent(object arg = null);
public event CloseEvent OnCloseEvent;
public sealed override void Close(object arg = null)
{
this.Log("Close() arg:{0}", arg);
if (this.gameObject.activeSelf)
{
this.gameObject.SetActive(false);
}
OnClose(arg);
if (OnCloseEvent != null)
{
OnCloseEvent(arg);
OnCloseEvent = null;
}
}
对不起,我认为它太长了。
谢谢!
答案 0 :(得分:3)
添加此支票。
llvm-dis