Class DisplayNameAttribute
Assigns a human-readable display name to a type for use in tooling, editor UI, and reflection-based systems throughout the Scylla framework.
Inherited Members
Namespace: Scylla.Core.Attributes
Assembly: ScyllaCore.dll
Syntax
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Interface, Inherited = false)]
public sealed class DisplayNameAttribute : Attribute
Remarks
Many framework systems and editor tools discover types dynamically via reflection and then present them to the user - for example, in type-selection dropdowns, filter windows, or documentation generators. By default these systems would show the raw C# class name, which can be cryptic or overly technical. Applying DisplayNameAttribute lets you provide a user-facing label that is completely independent of the underlying identifier.
The display name is stored in the read-only Name property and an optional human-readable Tooltip can be attached via the property initializer syntax. Both are pure metadata: they carry no runtime cost beyond attribute construction during initial reflection.
This attribute can be applied to classes, interfaces, and structs. It is
intentionally non-inherited (Inherited = false), so subclasses must
declare their own DisplayNameAttribute if they require a distinct
display name. This avoids silently propagating a parent's label to a child type
with a completely different purpose.
To suppress a type from appearing in filter or selection windows entirely, combine this attribute with HideInFilterWindowAttribute. To assign an organizational category, combine it with GroupAttribute.
Basic usage - override the type name shown in editor UI:
[DisplayName("Player Character")]
public class PlayerCharacterController : MonoBehaviour
{
/* ... */
}
With an optional tooltip that editor tools may surface on hover:
[DisplayName("AI Enemy", Tooltip = "Base class for all enemy AI behaviors")]
public abstract class EnemyAI : MonoBehaviour
{
/* ... */
}
Reading the attribute at runtime via reflection:
var attr = typeof(PlayerCharacterController)
.GetCustomAttribute<DisplayNameAttribute>();
if (attr != null)
Debug.Log(attr.Name); // "Player Character"
Constructors
DisplayNameAttribute(string)
Initializes a new DisplayNameAttribute with the required display name.
Declaration
public DisplayNameAttribute(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The human-readable label that tooling and editor UI should display instead of the raw C# type name. Must be a non-null, non-empty string. Spaces and special characters are allowed; this value is treated as a display string only, never as an identifier. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
Properties
Name
Gets the human-readable display name assigned to the decorated type.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| string | A non-null, non-empty string provided at construction time. This value is
immutable after the attribute is created. Editor tools and reflection-based
systems should use this property instead of |
Tooltip
Gets or sets an optional extended description of the type that editor tools may surface as a tooltip or supplemental help text.
Declaration
public string Tooltip { get; set; }
Property Value
| Type | Description |
|---|---|
| string | A human-readable description string, or |
Remarks
Set this property via the attribute initializer syntax:
[DisplayName("My Type", Tooltip = "Handles core logic for XYZ.")]
There is no runtime enforcement on the content of this string; it is pure display metadata. Keeping tooltips concise (one sentence) is recommended so they render well in space-constrained UI contexts.