- Home /
extending unity editor to simplify text editing (c#)
Hi, I have a public string field in a class, used to store a pretty long description of an item. The editor shows a text field to edit this value, as usual for a string. I read you could extend Unity Editor to customize the property inspectors.
Is there a way to make the editor for this string a Text Area instead of a Text Field?
thanks!
Manuel
Answer by burnumd · Jan 02, 2013 at 11:23 PM
In Unity 4.0, use the Multiline field attribute:
//C# Example
[Multiline]
public string myText = "";
//JS Example
@Multiline
public var myText : String = "";
Here's the documentation for it: http://docs.unity3d.com/Documentation/ScriptReference/MultilineAttribute.MultilineAttribute.html You can also do "[Multiline (5)]" or some other number to specify how many lines should be shown.
$$anonymous$$ultiline is fortunately built-in. If you want to write your own inspector bits (without writing an entire Inspector), there's the PropertyAttribute (which $$anonymous$$ultiline derives from): http://docs.unity3d.com/Documentation/ScriptReference/PropertyAttribute.html and PropertyDrawer class: http://docs.unity3d.com/Documentation/ScriptReference/PropertyDrawer.html
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Initialising List array for use in a custom Editor 1 Answer
Distribute terrain in zones 3 Answers
Getting GUI.skin in editor script changed entire Unity Editor GUI 1 Answer
Floating Point and ToString issue 2 Answers