I am making a simple script that changed GUI Text for people and manages what they say. But when I run this now unity says it is unable to cast from source type to destination type.
var inputkey1 = "1";
var inputkey2 = "2";
var inputkey3 = "3";
var inputkey4 = "4";
var inputmessage1 = "Dont Put the same inputer key in 2";
var inputmessage2 = "or it will print both lines at once!";
var inputmessage3 = "This is what inputkey3 will say!";
var inputmessage4 = "This is what inputerkey4 will say!";
private var gt : GUIText;
function Start()
{ gt.text = GetComponent(GUIText);
if( gt == null ) Debug.Log("No GUIText component found");
}
function Update ()
{
if(Input.GetKeyDown(inputkey1))
{ print ( inputmessage1 );
gt.text = inputmessage1; }
else if(Input.GetKeyDown(inputkey2))
{ print ( inputmessage2 );
gt.text = inputmessage2; }
else if(Input.GetKeyDown(inputkey3))
{ print ( inputmessage3 );
gt.text = inputmessage3; }
else if(Input.GetKeyDown(inputkey4))
{ print ( inputmessage4 );
gt.text = inputmessage4; }
}
asked
Feb 19 '11 at 08:30 AM
DevonJS
28
●
10
●
12
●
16