|
So the documentation here says: "You can also expose references to other objects to the inspector. Below you can drag a game object that contains the OtherScript on the target slot in the inspector." Now what if I have several scripts of that type in that GameObject, only the first one seems to be referenced. Is there a way to pick one from the inspector ?
(comments are locked)
|
|
(comments are locked)
|
|
You can use GetComponents or GetComponentsInChildren to get an array of them. How you distinguish them is up to you. Hey thx 4 the reply. I was working on a mechanism for the designer to be able to configure some kind of events between GameObjects, not to get them through code.
May 04 '11 at 03:37 PM
Agustin Petrini
(comments are locked)
|

Do you mean having several instances of the same script on the same game object? If so, I'm not sure what you mean...could you post some specific code?
Sorry if I wasnt clear. I mean having a variable in a script in GameObjectA of Type TypeB. Lets say I have GameObjectA with a couple of TypeB scripts . When I drag GameObjectB into the variable of GameObjectA only the first script is referenced. My question is if theres any way to specify which one gets referenced.