Game.UI.Widgets.EditorNameAttribute
Assembly: Assembly-CSharp.dll
Namespace: Game.UI.Widgets
Type: class
Base: UnityEngine.PropertyAttribute
Summary:
An attribute used to specify a custom display name for a field or property in the game's editor/UI. Attach this attribute to a serialized field to provide an alternative label that editors or custom property drawers can read and show instead of the member name. The attribute simply stores the provided display name string.
Fields
private string <displayName>k__BackingField
Backing field generated by the auto-implemented propertydisplayName
. Holds the value passed to the attribute constructor.
Properties
public string displayName { get; private set }
The display name provided when the attribute is applied. Readable publicly; the setter is private, so the value is fixed after construction. Editors or custom property drawers can read this property (via reflection or attribute APIs) to determine what label to show for the annotated member.
Constructors
public EditorNameAttribute(string displayName)
Creates a new EditorNameAttribute and stores the provided display name. Typical usage is to place this attribute above a serialized field so editor UI code can show the provided label instead of the field name.
Methods
- This class does not declare any additional methods beyond the constructor. It relies on the base PropertyAttribute behavior and only stores the display string.
Usage Example
using Game.UI.Widgets;
using UnityEngine;
public class MyComponent : MonoBehaviour
{
// In the editor UI, this field should be labeled "Player Display Name"
[SerializeField, EditorName("Player Display Name")]
private string playerName;
}
Notes: - Unity's default inspector will ignore custom attributes unless a corresponding PropertyDrawer or editor code reads and respects them. In Cities: Skylines 2, the game's custom UI/editor systems may look for this attribute to present the provided label. - Because the attribute stores the display name in a read-only property, the label is immutable after construction.