The following script is intended to transfer a Color from a variable in another script and 'visualise' that color by means of the GUI. Code below.
Help would be appreciated.
Gary
//this script reads the public colour variable from a
GameObject.Script.Variable (dataField1.DataField.ColorUnderCharacter)
and puts it on a square Box GUI.
var plainTex : Texture2D ;
var rayTexColor : Color = Color.white ;
var searchGameObject : GameObject ;
var searchScript : GameObject ;
function Start()
{
var accessGameObject = GameObject.Find("dataField1") ;
var accessScript = accessGameObject.GetComponent("DataField")
}
function Update ()
{
rayTexColor = accessScript.ColorUnderCharacter ;
print(rayTexColor.grayscale) ;
}
function OnGUI() {
//Find dataField data and set it to the current colour to paint the GUI
//Configure the Box, Draw Box, reset GUI
var c : Color = GUI.backgroundColor ;
GUI.backgroundColor = rayTexColor ;
GUI.Box(Rect(10,10,50,50)) ;
GUI.backgroundColor = c ;
}