- Home /
"Horizontal" script referencing in C#
I'm trying to switch over from Javascript to C#, as you might have guessed, and I'm just wondering about how I can get scripts to refer to scripts in the same script compilation stage.
I understand that they can refer to scripts from previous stages, but can they refer to to scripts in the SAME stage? If it's not possible, what are some suggested workarounds?
Thanks!
Answer by gregzo · Oct 01, 2012 at 01:14 PM
It is not possible.
I don't know of any workarounds besides porting your code : afaik "horizontal" referencing simply doesn't work if scripts are in different languages.
I meant in groups of only C# code. So no C# script can refer to another one in a same stage?
Of course they can! Use GetComponent or reference by drag and dropping in the inspector (drag script to -> reference to public variable).
Example : public OneOf$$anonymous$$yCsScripts refToOneOf$$anonymous$$yCsScripts;
drag an instance of "OneOf$$anonymous$$yCsScripts" to the field "refToOneOf$$anonymous$$yCsScripts" in the inspector, and you're done.
Your answer
![](https://koobas.hobune.stream/wayback/20220613081715im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Initialising List array for use in a custom Editor 1 Answer
Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer
Flip over an object (smooth transition) 3 Answers