Skip to content

Commit a05c185

Browse files
committed
Fix nullref on missing m_Calls
1 parent 835d543 commit a05c185

2 files changed

Lines changed: 36 additions & 12 deletions

File tree

‎RuntimeUnityEditor.Core.IL2CPP/Windows/ObjectTree/ObjectTreeViewer.cs‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,15 @@ private void DrawSingleComponent(Component component)
477477
for (var i = 0; i < eventObj.GetPersistentEventCount(); ++i)
478478
GUILayout.Label(ToStringConverter.EventEntryToString(eventObj, i));
479479

480-
var calls = (IList)eventObj.GetPrivateExplicit<UnityEventBase>("m_Calls").GetPrivate("m_RuntimeCalls");
481-
foreach (var call in calls)
482-
GUILayout.Label(ToStringConverter.ObjectToString(call.GetPrivate("Delegate")));
480+
try
481+
{
482+
var calls = (IList)eventObj.GetPrivateExplicit<UnityEventBase>("m_Calls").GetPrivate("m_RuntimeCalls");
483+
foreach (var call in calls)
484+
GUILayout.Label(ToStringConverter.ObjectToString(call.GetPrivate("Delegate")));
485+
}
486+
catch (NullReferenceException)
487+
{
488+
}
483489

484490
GUILayout.FlexibleSpace();
485491
if (GUILayout.Button("?"))
@@ -492,9 +498,15 @@ private void DrawSingleComponent(Component component)
492498
for (var i = 0; i < eventObj.GetPersistentEventCount(); ++i)
493499
GUILayout.Label(ToStringConverter.EventEntryToString(b.onValueChanged, i));
494500

495-
var calls = (IList)b.onValueChanged.GetPrivateExplicit<UnityEventBase>("m_Calls").GetPrivate("m_RuntimeCalls");
496-
foreach (var call in calls)
497-
GUILayout.Label(ToStringConverter.ObjectToString(call.GetPrivate("Delegate")));
501+
try
502+
{
503+
var calls = (IList)b.onValueChanged.GetPrivateExplicit<UnityEventBase>("m_Calls").GetPrivate("m_RuntimeCalls");
504+
foreach (var call in calls)
505+
GUILayout.Label(ToStringConverter.ObjectToString(call.GetPrivate("Delegate")));
506+
}
507+
catch (NullReferenceException)
508+
{
509+
}
498510

499511
GUILayout.FlexibleSpace();
500512
if (GUILayout.Button("?"))

‎RuntimeUnityEditor/Windows/ObjectTree/ObjectTreeViewer.cs‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,15 @@ private void DrawSingleComponent(Component component)
471471
for (var i = 0; i < eventObj.GetPersistentEventCount(); ++i)
472472
GUILayout.Label(ToStringConverter.EventEntryToString(eventObj, i));
473473

474-
var calls = (IList)eventObj.GetPrivateExplicit<UnityEventBase>("m_Calls").GetPrivate("m_RuntimeCalls");
475-
foreach (var call in calls)
476-
GUILayout.Label(ToStringConverter.ObjectToString(call.GetPrivate("Delegate")));
474+
try
475+
{
476+
var calls = (IList)eventObj.GetPrivateExplicit<UnityEventBase>("m_Calls").GetPrivate("m_RuntimeCalls");
477+
foreach (var call in calls)
478+
GUILayout.Label(ToStringConverter.ObjectToString(call.GetPrivate("Delegate")));
479+
}
480+
catch (NullReferenceException)
481+
{
482+
}
477483

478484
GUILayout.FlexibleSpace();
479485
if (GUILayout.Button("?"))
@@ -486,9 +492,15 @@ private void DrawSingleComponent(Component component)
486492
for (var i = 0; i < eventObj.GetPersistentEventCount(); ++i)
487493
GUILayout.Label(ToStringConverter.EventEntryToString(b.onValueChanged, i));
488494

489-
var calls = (IList)b.onValueChanged.GetPrivateExplicit<UnityEventBase>("m_Calls").GetPrivate("m_RuntimeCalls");
490-
foreach (var call in calls)
491-
GUILayout.Label(ToStringConverter.ObjectToString(call.GetPrivate("Delegate")));
495+
try
496+
{
497+
var calls = (IList)b.onValueChanged.GetPrivateExplicit<UnityEventBase>("m_Calls").GetPrivate("m_RuntimeCalls");
498+
foreach (var call in calls)
499+
GUILayout.Label(ToStringConverter.ObjectToString(call.GetPrivate("Delegate")));
500+
}
501+
catch (NullReferenceException)
502+
{
503+
}
492504

493505
GUILayout.FlexibleSpace();
494506
if (GUILayout.Button("?"))

0 commit comments

Comments
 (0)