You can access local variables by creating an instance of the script. As an example, lets say you have someVariable located in scriptA, which is attached to gameObjectA. You want to access it from scriptB, which is attached to gameObjectB.
Within scriptB:
function Update()
{
// Find the gameobject that scriptA is attached to
var instanceGO : GameObject.Find("gameObjectB");
// Create an instance of the script
var instanceScript : scriptA = instanceGO.GetComponent("scriptA");
// Set someVariable to 0.
instanceScript.scriptA.someVariable = 0;
}
↧