Having a bad day in regards to coding - I’m having problems understanding how to properly reference variables from other scripts, here’s the script I want to reference.
#pragma strict
var lightcolour : Color[];
public var selection;
var firstchange = 60;
var changerate = 60;
function Update ()
{
if(Time.time > changerate)
{
changerate = Time.time + firstchange;
var chance = Random.Range(1,10);
}
if(chance == 1)
{
selection = lightcolour [Random.Range(0, lightcolour.length)];
light.color = selection;
}
}
This script works perfectly, but I want to be able to reference the variable ‘selection’ in another script and use it to change the GUI.color property of a GUI texture so that the colour of the GUI texture is the same as the light.
I’m just not entirely sure how I do this, I’ve read the documentation but I don’t understand how to reference a variable from a script.
Thanks.