- Home /
Textfield Not Working - Cannot Select
Hello,
I have a OnGUI function with a text field in it. But I can't seem to select the textfield. Have I hover my mouse over it - the textfield it highlighted, but when I go to press on it, nothing happens.
What am I doing wrong? Here is my script:
// ---- SELECT CONTROL FOR POWERBOX!! ---- \\
static var currentObjectOver : GameObject; private var objectSelected : GameObject; static var cursorFound : boolean = false;
private var search : boolean = true;
static var toggleClick : boolean = false; private var mouseOnX = 0; private var mouseOnY = 0;
var cursor : Texture2D; var cursorOn : Texture2D; var cursorMouse : Texture2D; var currentCursor : Texture2D; private var cursorSize: int = 16; // set to width of your cursor texture static var itemName : String;
function Start(){ //Screen.showCursor = false; Screen.showCursor = true; currentCursor = cursor; }
function Update () { Screen.showCursor = true;
}
// ----------- GUI Controller - Function of Objects -------------- \\ var username : String = "Adam Smith"; var password : String = "My Password"; static var stringCode : String = "";
function OnGUI(){
// -- Password Control -- \\ -- HERE IS THE PROBLEM >>
if(ComputerControl.computerPass == true){
stringCode = GUI.TextField (Rect (30, 70, 200, 20), stringCode, 4);
GUI.BeginGroup (new Rect (Screen.width / 2 - 150, Screen.height / 2 - 100, 300, 200));
GUI.Box (new Rect (0,0,300,200),"Password Box");
//GUI.TextField (Rect (30, 70, 200, 20), username, 25);
GUI.PasswordField (Rect (30, 100, 200, 20), password, "*"[0], 25);
GUI.Button(Rect(30,140,50,30),"Login");
if(GUI.Button(Rect(100,140,50,30),"Exit")){
ComputerControl.powerOff = true;
}
GUI.EndGroup();
}
// -- Computer Screen -- \\
if(objectSelected.gameObject.name == "Logout" && StoryControl.Computer == true){
ComputerControl.powerOff = true;
clearGameCache();
}
if(objectSelected.gameObject.name == "Email" && StoryControl.Computer == true){
//ComputerControl.powerOff = true;
clearGameCache();
}
if(objectSelected.gameObject.name == "Documents" && StoryControl.Computer == true){
//ComputerControl.powerOff = true;
clearGameCache();
}
// -- enable camera freeze up -- \\
/*
if(toggleClick == true){
MouseLook.headLock = true;
MouseLook.lockGUI = true;
}*/
} function startGameCache(){ toggleClick = true; objectSelected = currentObjectOver; mouseOnX = Input.mousePosition.x; mouseOnY = Screen.height - Input.mousePosition.y; search = false; return; }
function clearGameCache(){ toggleClick = false; objectSelected = null; search = true; //MouseLook.lockGUI = false; //MouseLook.headLock = false;
return; }
Answer by Serellyn · Oct 12, 2012 at 08:48 AM
Hey Oliver did you ever resolve this problem? And are you shutting down a computer with this program? Because I'm looking into that if that's possible with Unity, but I can't find out how.
Your answer
![](https://koobas.hobune.stream/wayback/20220613110420im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
GUILayout.TextField doesn't accept inputs 1 Answer
Type in TextField to make buttons press and vice versa 0 Answers
calling a class named by a string -1 Answers
how suppress must be instantiated using the ScriptableObject.CreateInstance method warning? 1 Answer
Checking if variable is nullable type? 3 Answers