diff --git a/ScriptCore/Editor/EntityEditor.cs b/ScriptCore/Editor/EntityEditor.cs index a6dea52..32ee1e8 100644 --- a/ScriptCore/Editor/EntityEditor.cs +++ b/ScriptCore/Editor/EntityEditor.cs @@ -852,7 +852,18 @@ internal class EntityEditor IEnumerable attributes = field.GetCustomAttributes(); - string prettyName = field.Name.ToPrettyName(); + LabelAttribute? label = GetAttribute(attributes); + + string prettyName; + + if (label != null) + { + prettyName = label.Label ?? field.Name; + } + else + { + prettyName = field.Name.ToPrettyName(); + } object? newValue = ShowFieldEditor(value, value?.GetType() ?? field.FieldType, prettyName, attributes); diff --git a/ScriptCore/Editor/LabelAttribute.cs b/ScriptCore/Editor/LabelAttribute.cs new file mode 100644 index 0000000..61adcd3 --- /dev/null +++ b/ScriptCore/Editor/LabelAttribute.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace GlitchyEngine.Editor; + +/// +/// Specifies a string that will be shown as the label of the field in the editor. +/// +[AttributeUsage(AttributeTargets.Field)] +public sealed class LabelAttribute : Attribute +{ + /// + /// The label of the field. If , the actual field name will be shown instead of the "prettified" name that is shown for fields without the . + /// + public string? Label { get; private set; } + + /// + /// Initializes a new instance of the with a minimum, maximum value and optionally a speed. + /// + /// + public LabelAttribute(string? label) + { + Label = label; + } +}