Search Unity

GUI.FocusControl always keep focus

Discussion in 'Scripting' started by henriquerafael85, Oct 21, 2014.

  1. henriquerafael85

    henriquerafael85

    Joined:
    Mar 16, 2013
    Posts:
    14
    I made this code:

    bool key = true;
    void OnGUI () {
    //if(key){
    //key=false;
    GUI.SetNextControlName ("next");
    GUI.FocusControl ("next");
    //}
    GUI.TextField (new Rect (0, 0, 1000, 50), "no text");
    }

    I want the focus on the control is done only once (just like when you click on the control), allowing the player to become out of focus whenever he wants (PC or mobile). But how is the code, it will always focus on the control.
    Is there a way to cause the focus to be called only once, leaving the rest to the player?