Title Attribute特性:用于在屬性上方生成粗體標(biāo)題站玄。
直接設(shè)置標(biāo)題坤学,或者添加標(biāo)題和副標(biāo)題
[Title("Static title")]
public int C;
public int D;
[Title("Static title", "Static subtitle")]
public int E;
public int F;
還可以設(shè)置標(biāo)題是否為粗體和是否含有對(duì)應(yīng)的下劃線
[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;
也可以設(shè)置標(biāo)題的不同布局
[Title("$MyTitle", "$MySubtitle", TitleAlignments.Right)]
public int M;
public int N;
[Title("$MyTitle", "$MySubtitle", TitleAlignments.Centered)]
public int O;
public int P;
[Title("$MyTitle", "$MySubtitle", titleAlignment: TitleAlignments.Left)]
public int Q;
public int R;
[Title("$MyTitle", "$MySubtitle", titleAlignment: TitleAlignments.Split)]
public int S;
public int T;
同樣膨更,可是用特殊標(biāo)識(shí)符$來獲取一個(gè)屬性字段或者函數(shù)的返回值作為消息內(nèi)容
也可以使用特殊標(biāo)識(shí)符@將方法體以字符串的形式當(dāng)實(shí)參傳入進(jìn)去
完整示例代碼
using Sirenix.OdinInspector;
using UnityEngine;
public class TitleAttributeExample : MonoBehaviour
{
[Title("Titles and Headers")]
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("$MyTitle", "$MySubtitle", titleAlignment: TitleAlignments.Left)]
public int Q;
public int R;
[Title("$MyTitle", "$MySubtitle", titleAlignment: TitleAlignments.Split)]
public int S;
public int T;
[ShowInInspector]
[Title("Title on a Property")]
public int U { get; set; }
[Title("Title on a Method")]
[Button]
public void DoNothing()
{ }
[Title("@DateTime.Now.ToString(\"dd:MM:yyyy\")", "@DateTime.Now.ToString(\"HH:mm:ss\")")]
public int Expresion;
public string Combined { get { return this.MyTitle + " - " + this.MySubtitle; } }
}