Class InfoBoxAttribute
Displays an informational, warning, or error message box immediately above the decorated field in the Unity Inspector.
Inherited Members
Namespace: Scylla.Core.Attributes
Assembly: ScyllaCore.dll
Syntax
[AttributeUsage(AttributeTargets.Field)]
public sealed class InfoBoxAttribute : PropertyAttribute
Remarks
This attribute is intended for embedding contextual guidance, caveats, and important warnings directly in the Inspector, reducing the need for designers to consult external documentation. The InfoType parameter controls the icon and visual style of the box:
- None - a plain box with no icon, suitable for neutral notes.
- Info - a blue box with an info icon, suitable for general guidance or context.
- Warning - a yellow box with a warning icon, suitable for potential pitfalls or configuration constraints.
- Error - a red box with an error icon, suitable for critical restrictions or values that must not be changed in production.
The info box is always visible regardless of the field's value; it is not conditional. To show an info box only under certain conditions, combine this attribute with ShowIfAttribute on the same field.
public class NetworkSettings : MonoBehaviour
{
[InfoBox("Higher tick rates improve accuracy but increase CPU load.", InfoType.Info)]
[SerializeField] private int _tickRate = 60;
[InfoBox("Values above 0.5 may cause visible lag spikes on slow connections.", InfoType.Warning)]
[SerializeField] private float _syncInterval = 0.1f;
[InfoBox("Do not enable in production builds - exposes internal state.", InfoType.Error)]
[SerializeField] private bool _debugMode = false;
/* Plain note without an icon */
[InfoBox("Set this to match your server region.", InfoType.None)]
[SerializeField] private string _serverRegion = "EU";
}
Constructors
InfoBoxAttribute(string, InfoType)
Creates an info box that displays the specified message above the decorated field in the Inspector.
Declaration
public InfoBoxAttribute(string message, InfoType type = InfoType.Info)
Parameters
| Type | Name | Description |
|---|---|---|
| string | message | The text to display inside the message box. Must not be |
| InfoType | type | The visual style of the box, controlling the icon displayed alongside the message. Defaults to Info (blue info icon). Pass a different InfoType value to use a warning or error style. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
Properties
Message
Gets the text content displayed inside the info box.
Declaration
public string Message { get; }
Property Value
| Type | Description |
|---|---|
| string | A non-null, non-empty string set at construction time. The text is rendered as plain text in the Inspector's HelpBox control. |
Type
Gets the visual style of the info box, which determines the icon and color scheme rendered by the Inspector drawer.
Declaration
public InfoType Type { get; }
Property Value
| Type | Description |
|---|---|
| InfoType | One of the InfoType enum values: None, Info, Warning, or Error. Defaults to Info when not specified in the constructor. |