Skip to content

Commit ce40e56

Browse files
committed
Avoid NRE when destroying propbatcher
1 parent 171522a commit ce40e56

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

RasterPropMonitor/Auxiliary modules/PropBatcher.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,15 @@ void LateUpdate()
329329

330330
void OnDestroy()
331331
{
332-
RasterPropMonitorComputer rpmComp = RasterPropMonitorComputer.FindFromProp(internalProp);
333-
foreach (var labelBatch in labelBatches)
332+
if (part != null)
334333
{
335-
if (labelBatch.Key.variableName != null)
334+
RasterPropMonitorComputer rpmComp = RasterPropMonitorComputer.FindFromProp(internalProp);
335+
foreach (var labelBatch in labelBatches)
336336
{
337-
rpmComp.UnregisterVariableCallback(labelBatch.Key.variableName, labelBatch.Value.VariableChangedCallback);
337+
if (labelBatch.Key.variableName != null)
338+
{
339+
rpmComp.UnregisterVariableCallback(labelBatch.Key.variableName, labelBatch.Value.VariableChangedCallback);
340+
}
338341
}
339342
}
340343
}

0 commit comments

Comments
 (0)