Having had a good poke around...
I am trying to transfer a Color from a variable (ColorUnderCharacter) in a script (DataField) on another GameObject (dataField1,dataField2,n) to a GUI.Box.
And I have got this far with the basic script.
FYI; Ultimately, I am looking to see a GUI box displaying separated R,G & B colour values (0-255) for each of the ColorUnderCharacter Colors for each of the dataField1,n Objects.
Develops on previous SUCCESS: http://answers.unity3d.com/questions/45454/extracting-rgb-component-data-from-a-textured-plane-positioned-below-a-3d-terrain (Thanks to YoYo)
Where I think that there are Syntax Errors, I have marked the //<>
//read the base texture for GUI background (actually 32,32 Color.white)
var plainTex : Texture2D ;
//creates a style for the GUI.Box
var colorStyle : GUIStyle ;
//variable to store data from (GameObject.dataField1.DataField script)
var rayTexColor : Color = Color.white ;
//Will be a Search string <<THINK: could use Array when reading multiple GameObject.dataField1 & dataField2 etc objects>>
var gameObjectName : GameObject;
function OnGUI () {
if(!plainTex){
Debug.LogError("Missing Texture File") ;
}
if (!gameObjectName){
Debug.LogError("No GameObject Listed") ;
}
//Find dataField data and set it to the current colour to paint the GUI
GameObject.Find(gameObjectName).GetComponent.DataField.ColorUnderCharacter = rayTexColor ; //<<SYNTAX ERROR??>>
print(rayTexColor.grayscale) ;
//Configure the Box
GUILayout.Box(plainTex) ;
GUIStyle.normal.background = rayTexColor ; //<<SYNTAX ERROR??>>
//Draw the Box
GUI.Box(Rect(200,200,200,200), gameObjectName, colorStyle) ;
}