I am making some localized tips to be displayed when my player enters an area.
These tips are displayed over the characters head.
I have a gameObject with an exposed string, so that I can place tips around my scene, and enter the message I want to have displayed. The string is then passed forward to a TextMesh when the character collides with the tip.
The problem I am encountering is entering new line (
) into the string in the inspector.
The escape character is shown in inspector but is left out in game ( the '\' is gone, but not the 'n').
I have tried entering
by using alt + enter ( as suggested in the reference manual ).
But it doesn't seem to work.
Has anyone managed to input newlines through the inspector? (how the hell did you do that :o?)
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor(typeof(TextMesh))]
public class TextEditor : Editor {
public override void OnInspectorGUI () {
this.DrawDefaultInspector();
TextMesh current_target = target as TextMesh;
EditorGUILayout.LabelField(" Text:", "");
current_target.text = EditorGUILayout.TextArea( current_target.text,GUILayout.MaxHeight(500f));
}
}
I have a string which i should assign through the inspector.
My solution is, that i added the [TextArea] attribute, now i can use my Enter key and everything works like expected.
Add the TextAreaAttribute to your string variable, and the Inspector will now provide you with a larger text entry box that allows you to just use the Enter key to make carriage returns. Yay!