I’m creating a custom editor for rich text, and am partially stumped using the TextEditor to check the SelectedText, while keeping the ability to access shortcuts for stuff like undo and save.
GUILayout.TextArea is able to give access to TextEditor for the information I want in order to add rich text to a selection, but prevents any shortcuts from being detected.
TextEditor txtedt = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
EditorGUI.BeginChangeCheck();
string changedText = GUILayout.TextArea(currentText);//prevents shortcuts from being detected
if(EditorGUI.EndChangeCheck()){
Undo.RegisterCompleteObjectUndo(this, "change text");
currentText = changedText
}
Debug.Log(txtedt.SelectedText)//prints currently highlighted text I would expect
EditorGUILayout.TextArea allows shortcuts to be detected, but TextEditor does not relay any information to TextEditor
TextEditor txtedt = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
EditorGUI.BeginChangeCheck();
string changedText = EditorGUILayout.TextArea(currentText);//does not relay changes to txtedt
if(EditorGUI.EndChangeCheck()){
Undo.RegisterCompleteObjectUndo(this, "change text");
currentText = changedText
}
Debug.Log(txtedt.SelectedText)// is empty
Is there any way to have both the ability to get information on the SelectedText, while being able to access shortcuts? Am I using EditorGUILayout.TextArea or GUILayout.TextArea wrongly?
Im using Unity 2021.1.16f in case that matters.