Fix weird Behaviour inheritance issue

This commit is contained in:
Sinai 2022-04-19 00:57:13 +10:00
parent 70d67f1dad
commit 5a3cad9be2

View File

@ -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<Behaviour>, 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);
}