Cross Referencing Between UnityScript and C#

Would anyone mind giving me an example of how referencing a GameObject/componenet from UnityScript to a C# script and vise versa?

Thanks!

Unityscript and C# can’t see each other at compile time, but scripts already compiled are visible to any language. The compilation order is: scripts saved in folders Plugins or Standard Assets, then scripts stored in their Editor subfolders, and finally scripts from other folders (see Script Compilation). Unfortunately, the other way around isn’t possible: a compiler in the first group can’t see scripts of the second group, for instance.

If the compile order problem is solved, you can access variables or execute functions in different scripts getting the target script with GetComponent, like this:

var cScript: ScriptName = objectReference.GetComponent(ScriptName);
cScript.health -= 1;

or in C#:

ScriptName jsScript = objectReference.<ScriptName>();
jsScript.health -= 1;

where objectReference is any reference (gameObject, transform, collider etc.) to the object to which the script called ScriptName is attached. If both scripts are attached to the same object, you can use GetComponent without the object reference.

You can read more detailed info about accessing variables or functions in different objects in the docs: http://unity3d.com/support/documentation/ScriptReference/index.Accessing_Other_Game_Objects.html

NOTE: There’s a limited way to execute a function independently of language or compile order: use SendMessage, SendMessageUpwards or BroadcastMessage: they call the function specified with an optional single argument of any type, but can’t return any value. Once again, a reference to the target object is required if it’s a different one:

objectReference.SendMessage("FunctionName", anyArgument);

So, if the C# script is placed in the standard assets folder, it will compile first, which is what I want right? I want the C# script to be there and ready when the JS file Im using to access the C# is compiled, it should find the component? Should the JS file not be in Standard Assets with it? Should it be in one of the editor files?