Search Unity

Toggle Input Field interactivity

Discussion in 'UGUI & TextMesh Pro' started by elpuerco63, May 15, 2017.

  1. elpuerco63

    elpuerco63

    Joined:
    Jun 26, 2014
    Posts:
    271
    I have a GameObject that can be dragged by the user which contains a InputField object. To stop the keyboard keep appearing when the user touches the GameObject I have an edit button that the user can tap to enable/disable editing which call this code:

    Code (csharp):
    1.  
    2. input.GetComponent<InputField> ().interactable = !input.GetComponent<InputField> ().interactable;
    3.  
    But this is proving very inconsistent in that sometimes I have to tap the edit button a few times or more to get the enable/disable I expect to work.

    Basically I need the user to be able to drag the GameObject about and only present the keyboard when the user expresses their wish to enter text.

    Is this the way to go about it?