I am closely following the reference manual here and essentially trying to get it working as per the given example.
http://unity3d.com/support/documentation/ScriptReference/index.Accessing_Other_Game_Objects.html
I have created 2 scripts, one to change a variable in the other
“Test”
// Set foo DoSomething on the target variable assigned in the inspector.
var target : testfoo;
function Update () {
// Set foo variable of the target object
target.foo = 2;
Debug.Log("target.foo" + target.foo);
}
and “testfoo”
var foo = 20;
function Update () {
}
When I do this I get an exposed slot and I then create a sphere, attach testfoo to it and drag it onto the slot. The screen shows the loading icon at the bottom right however it still says “none” as per the following picture.

When trying to run this the error in the debug log is
You need to drag your testfoo onto an instance of Test that’s attached to a game object (in the Hierarchy pane), not directly onto the script in the Project pane.
This would give me two scripts on the same object?
Maybe I have misunderstood your comment.
To clarify I am following the reference guide very clearly and doing the following
-
Create a sphere with testfoo, and initialise a variable type set to foo, which is the other script
-
Create another sphere with foo on which just defines the variable to be accessed
-
Drag the actual sphere in the heirarchy onto the exposed slot in testfoo
Update: I didnt create a second sphere before, having made objects for both now running after doing this crashes the editor.
The following screen now shows my attempt at passing variables, between one ball and another, one has foo and the other testfoo. This also shows my drag and drop process.
At the very least this shouldnt crash the editor, I have checked and it isnt a circular reference(something I had suspected).
Can someone post a unity scene containing this if they happen to have used this function.
Otherwise I’m really stuck, I cannot pass variables between scripts without using the slow method, which I dont want to.
Solved.
There appears to be a slight bugginess in this function.
Creating the objects again fixed this
Also for anyone reading this you need to have 2 objects, both scripts need to be on objects. If it crashes just try creating new objects and reattaching scripts.
Hey Rman, I was just having this same problem and after about 2hrs of banging my head I figured it out. Its one of those really simple things that you just wish someone would just tell you about.
To the right side of the inspector where your script is attached to your object, there is a little gear icon. If you click it, it brings up the “reset”, “edit component”, “edit script” options. You just have to go to reset, and it updates your changes. Simply saving is not enough if you have a public variable in there.