From 5a3cad9be2a4a53a63c984fc89f61081886f9cec Mon Sep 17 00:00:00 2001 From: Sinai <49360850+sinai-dev@users.noreply.github.com> Date: Tue, 19 Apr 2022 00:57:13 +1000 Subject: [PATCH] Fix weird Behaviour inheritance issue --- src/Inspectors/GameObjectInspector.cs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Inspectors/GameObjectInspector.cs b/src/Inspectors/GameObjectInspector.cs index e179601..a696f66 100644 --- a/src/Inspectors/GameObjectInspector.cs +++ b/src/Inspectors/GameObjectInspector.cs @@ -193,7 +193,8 @@ namespace UnityExplorer.Inspectors compInstanceIDs.Clear(); foreach (Component comp in comps) { - if (!comp) continue; + if (!comp) + continue; componentEntries.Add(comp); compInstanceIDs.Add(comp.GetInstanceID()); } @@ -202,8 +203,23 @@ namespace UnityExplorer.Inspectors behaviourEnabledStates.Clear(); foreach (Behaviour behaviour in behaviours) { - if (!behaviour) continue; - behaviourEntries.Add(behaviour); + if (!behaviour) + continue; + + // Don't ask me how, but in some games this can be true for certain components. + // They get picked up from GetComponents, but they are not actually Behaviour...? + if (!typeof(Behaviour).IsAssignableFrom(behaviour.GetType())) + continue; + + try + { + behaviourEntries.Add(behaviour); + } + catch (Exception ex) + { + ExplorerCore.LogWarning(ex); + } + behaviourEnabledStates.Add(behaviour.enabled); }