Hey everyone,
Is there a way to create a list of all the attached scripts on an object? I have tried several ways:
-
Creating a global list of type MonoBehavior and attempting to populate it as below:
public scriptList as List[of MonoBehaviour] def Start(): go as (MonoBehavior) = GetComponents[of MonoBehavior]() <pre>` for item in go: scriptList.Add(item as MonoBehavior)
`
But I get a 'NullReferenceException: Object reference not set to an instance of an object' and can't seem to find a way around it.
-
Manually creating a list
addedScript as ExampleScript addedScript = GetComponent[of ExampleScript]() scriptList as List = [addedScript]
However, I cannot reference in the item in the list by doing something like
scriptList[0].someVariable
because it gives me a 'BCE0019: 'someVariable' is not a member of 'object'.' error.1.
Does anyone know of a way to do this?
Thanks!
1.