TitleAttribute

Title is used to make a bold header above a property.

namespace Sirenix.OdinInspector
{
[AttributeUsageAttribute((AttributeTargets)448, AllowMultiple = False, Inherited = True)]
[DontApplyToListElementsAttribute]
public class TitleAttribute : Attribute
}

Requirements

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector
Version: 1.0.5.0

See Also

Constructors

Definition Description
TitleAttribute(string, string, TitleAlignments, bool, bool) Creates a title above any property in the inspector.

Properties

Return Type Definition Description
bool Bold If true the title will be dispalyed with a bold font.
bool HorizontalLine Gets a value indicating whether or not to draw a horizontal line below the title.
string Subtitle Optional subtitle.
string Title The title displayed above the property in the inspector.
TitleAlignments TitleAlignment Title alignment.

Example

The following example shows how Title is used on different properties.
public class TitleExamples : MonoBehaviour
{
    [Title("Titles and Headers")]
    [InfoBox(
        "The Title attribute has the same purpose as Unity's Header attribute," +
        "but it also supports properties, and methods." +
        "\n\nTitle also offers more features such as subtitles, options for horizontal underline, bold text and text alignment." +
        "\n\nBoth attributes, with Odin, supports either static strings, or refering to members strings by adding a $ in front.")]
    public string MyTitle = "My Dynamic Title";
    public string MySubtitle = "My Dynamic Subtitle";

    [Title("Static title")]
    public int C;
    public int D;

    [Title("Static title", "Static subtitle")]
    public int E;
    public int F;

    [Title("$MyTitle", "$MySubtitle")]
    public int G;
    public int H;

    [Title("Non bold title", "$MySubtitle", bold: false)]
    public int I;
    public int J;

    [Title("Non bold title", "With no line seperator", horizontalLine: false, bold: false)]
    public int K;
    public int L;

    [Title("$MyTitle", "$MySubtitle", TitleAlignments.Right)]
    public int M;
    public int N;

    [Title("$MyTitle", "$MySubtitle", TitleAlignments.Centered)]
    public int O;
    public int P;

    [Title("$Combined", titleAlignment: TitleAlignments.Centered)]
    public int Q;
    public int R;

    [ShowInInspector]
    [Title("Title on a Property")]
    public int S { get; set; }

    [Title("Title on a Method")]
    [Button]
    public void DoNothing()
    { }

    public string Combined { get { return this.MyTitle + " - " + this.MySubtitle; } }
}