Hello there,
In the game I am making the player has a phone and as soon as the phoneBool = true, onGUI draws the phone gui, with a text saying: … is calling. The … is a name randomly picked from a a list. The problem is that onGUI runs every frame and thus every frame the name of the caller gets changed. I have been trying to fix this for the past days but I can’t seem to do it. I have tried while loops at the name generation but that didn’t work.
The code for the name generation is:
function getName(){
var rName : String;
var rNumber: float;
var myClientel : int;
rNumber = Random.value;
myClientel = Mathf.RoundToInt(6 * rNumber + 1);
switch(myClientel){
case 1: rName = "Rio";
break;
case 2: rName = "De'Range";
break;
case 3: rName = "Detroit-De";
break;
}
return rName;
}
The code for the name displaying is:
var rNames: String = getName();
GUI.Box(Rect(300, 150, 190, 125), rNames +" is Calling" );
I hope you guys can help me.
Thanks in advance, Zenthor