Search Unity

How to get caret position of EditorGUI.TextArea

Discussion in 'Scripting' started by MackThax, May 16, 2017.

  1. MackThax

    MackThax

    Joined:
    Jan 30, 2015
    Posts:
    2
    How can I get the caret position of an EditorGUI.TestArea?
    I tried this but GUIUtility.keyboardControl returns 0.
     
  2. JoshuaMcKenzie

    JoshuaMcKenzie

    Joined:
    Jun 20, 2015
    Posts:
    916
    do you have the text field in focus? keyboardControl returns the id of the object thats currently in focus so if nothing is in focus it'd return 0. at which point GetStateObject will create a new state for id 0. and keep that state across future frames
     
  3. friuns

    friuns

    Joined:
    Jan 14, 2016
    Posts:
    23
    yeah same here it works with GUILayout but not works with EditorGUILayout