GetComponent with multiple identical script instances

Dearest forum

I have an object with multiple instances of the same script attached. Each script has a unique public variable set in the editor, in this case theAxis. Is it possible to access a specific one of the scripts from another object using the GetCompoenent?

It seams like it’s only possible to gain access to the first script using GetComponent.

The reason why I don’t just create multiple scripts with different names is to reduce the amount of scripts in my already crowded Asset library. Each script is deciding the objects behaviour along the x, y and z axis respectively.

Any ideas are very welcome
~Carl Email

I think you’ll have to get all the components of the type you want then find the one you’re looking for by looping through the variables that distinguish them as different.

Either that, or just organize your project folder so that tons of scripts aren’t too big of a deal. :slight_smile:

Cool, how is that done?

GetComponents

Oh :sweat_smile:

Once I found the right keyword to search for I found the same answer in an earlier thread:
http://forum.unity3d.com/viewtopic.php?t=7617

Thanks