Class MonoTextAreaAttribute
Displays a string serialized field as a scrollable, multi-line text area
rendered with the Scylla default monospace font (ScyllaMono) in the Unity
Inspector.
Inherited Members
Namespace: Scylla.Core.Attributes
Assembly: ScyllaCore.dll
Syntax
[AttributeUsage(AttributeTargets.Field)]
public sealed class MonoTextAreaAttribute : PropertyAttribute
Remarks
This attribute is functionally similar to Unity's built-in UnityEngine.TextAreaAttribute, but overrides the font with a monospace typeface. This makes it significantly more readable for content that relies on character alignment, such as:
- ASCII art and box-drawing character layouts
- Inline script or configuration snippets
- Tabular text or fixed-width formatted strings
- Log output previews
The text area grows vertically to accommodate content up to MaxLines visible rows, and maintains a minimum height of MinLines rows even when the content is shorter. Both line count bounds are clamped during construction: MinLines is clamped to at least 1, and MaxLines is clamped to at least MinLines.
The monospace font is loaded via LoadDefaultMono() and cached by the custom property drawer for efficient rendering across multiple fields.
public class MyConfig : ScriptableObject
{
/* Default 3 min, 8 max lines - suitable for short text blocks */
[MonoTextArea]
public string WelcomeMessage;
/* Custom line range for longer content like ASCII maps */
[MonoTextArea(5, 20)]
public string LevelLayout;
/* Minimum single-line, maximum 4-line monospace snippet */
[MonoTextArea(1, 4)]
public string ShaderSnippet;
}
Constructors
MonoTextAreaAttribute()
Creates a monospace text area with the default line count bounds: DEFAULT_MIN_LINES (3) minimum lines and DEFAULT_MAX_LINES (8) maximum lines.
Declaration
public MonoTextAreaAttribute()
MonoTextAreaAttribute(int, int)
Creates a monospace text area with explicitly specified minimum and maximum visible line counts.
Declaration
public MonoTextAreaAttribute(int minLines, int maxLines)
Parameters
| Type | Name | Description |
|---|---|---|
| int | minLines | The minimum number of lines the text area always occupies, even when the content is shorter. Values below 1 are clamped to 1. |
| int | maxLines | The maximum number of lines the text area grows to before becoming scrollable.
Values below |
Fields
DEFAULT_MAX_LINES
The default maximum number of visible text lines used when no explicit MaxLines value is provided at construction.
Declaration
public const int DEFAULT_MAX_LINES = 8
Field Value
| Type | Description |
|---|---|
| int |
Remarks
Applied when using the parameterless constructor. Value is 8, which
prevents the text area from expanding into an excessively tall control while
still accommodating reasonably sized text blocks.
DEFAULT_MIN_LINES
The default minimum number of visible text lines used when no explicit MinLines value is provided at construction.
Declaration
public const int DEFAULT_MIN_LINES = 3
Field Value
| Type | Description |
|---|---|
| int |
Remarks
Applied when using the parameterless constructor. Value is 3, which
provides enough vertical space for a short multi-line message without
consuming excessive Inspector real estate.
Properties
MaxLines
Gets the maximum number of text lines the text area will grow to before introducing a vertical scrollbar.
Declaration
public int MaxLines { get; }
Property Value
| Type | Description |
|---|---|
| int | A positive integer (minimum equal to MinLines) representing the maximum number of visible lines before scrolling is introduced. |
Remarks
Clamped to at least MinLines during construction via
Mathf.Max(MinLines, maxLines), so it is never less than the minimum.
Once the content exceeds this height, the text area becomes scrollable rather
than continuing to expand downward.
MinLines
Gets the minimum number of text lines that the text area will always display, even when the content is shorter than this height.
Declaration
public int MinLines { get; }
Property Value
| Type | Description |
|---|---|
| int | A positive integer (minimum 1) representing the guaranteed minimum height of the text area in lines. |
Remarks
Clamped to at least 1 during construction via Mathf.Max(1, minLines).
Setting a higher minimum reserves Inspector space for the field, which can
be useful to indicate to users that longer content is expected.