- Home /
This question was
closed Aug 07, 2013 at 01:55 AM by
AlucardJay for the following reason:
Duplicate Question : http://answers.unity3d.com/questions/509032/ai-logic-in-javascript.html
ai to input value
how would i get an ai to input value after player has entered a value in the bid section?
#pragma strict
var information: String;
private var guiOn = false;
private var rect: Rect;
var btnTexture : Texture;
var ClosePostion : Vector2 = new Vector2 (200,5);
var CloseSize : Vector2 = new Vector2 (35,35);
var CloseIcon : Texture;
var MyString = "";
//click to open gui
function OnMouseDown(){
guiOn = true;
rect = Rect(Input.mousePosition.x, Input.mousePosition.y, 300, 100);
yield WaitForSeconds(500);
guiOn = false;
}
function OnGUI(){
if (guiOn){
GUI.Box(Rect(0,0,200,200),"Current bid");
if (!btnTexture) {
Debug.LogError("Assign a texture");
return;
}
if (GUI.Button(Rect(10,10,50,50),btnTexture))
Debug.Log("texturebutton");
if (GUI.Button(Rect(10,70,50,30),"Bid")) {
var bid : int;
if (!int.TryParse(MyString, bid))
bid = 0;
Debug.Log("The bid was: "+bid);
}
var temp = "";
for (var c : char in MyString) {
if (c >= "0"[0] && c <= "9"[0]) {
temp += c;
}
}
MyString = temp;
MyString = GUI.TextField(new Rect(10,130,180,20),MyString,30);
//close button
if (GUI.Button(Rect(160,2,CloseSize.x,CloseSize.y),CloseIcon)) {
guiOn = false;
}
}
}
Comment