I need to assign the script values for the following Prefab in Unity 3.5
The structure is the following
Kinect_Prefab
-MonoBehaviour
·Script: Missing Mono Script
-MonoBehaviour
·Script: Missing Mono Script
-MonoBehaviour
·Script: Missing Mono Script
-MonoBehaviour
·Script: Missing Mono Script
All the components have the same name.
I have tried to obtain all of them in an array, but the GetComponents
method does not seem to work properly.
var mono : MonoBehaviour[];
mono = Kinect_Prefab.GetComponents(MonoBehaviour);
The thing is the resulting array is empty.
Any idea what might be wrong?
EDIT: When I do GetComponents(MonoBehaviour) I get the following error
InvalidCastException: Cannot cast from source type to destination type.
I have tried receiving the components in var mono : Component [] but I still don't receive anything
GetComponent
do you get a single component back? Why are you using the base class MonoBehaviour instead of something you implemented? \$\endgroup\$AddComponent
instead and what you're asking doesn't make any sense. What does the prefab look like in the inspector? \$\endgroup\$