Tab Group Attribute特性:可用于任何屬性掸掏,并將屬性組織到不同的選項(xiàng)卡中杯拐。使用它來組織不同的值冒掌,以使清潔檢查器變得易于使用筐赔。
【TabGroup】創(chuàng)建一個(gè)選項(xiàng)卡組 并指定選項(xiàng)卡組的名稱
[TabGroup("Tab A")]
public int One;
[TabGroup("Tab A")]
public int Two;
[TabGroup("Tab A")]
public int Three;
[TabGroup("Tab B")]
public string MyString;
[TabGroup("Tab B")]
public float MyFloat;
[TabGroup("Tab C")]
[HideLabel]
public MyTabObject TabC;
也可以為選項(xiàng)卡指定對(duì)應(yīng)的組
[TabGroup("New Group", "Tab A")]
public int A;
[TabGroup("New Group", "Tab A")]
public int B;
[TabGroup("New Group", "Tab A")]
public int C;
[TabGroup("New Group", "Tab B")]
public string D;
[TabGroup("New Group", "Tab B")]
public float E;
[TabGroup("New Group", "Tab C")]
public MyTabObject F;
[Serializable]
public class MyTabObject
{
public int A;
public int B;
public int C;
}
嵌套復(fù)雜的情況
[TitleGroup("Tabs")]
[HorizontalGroup("Tabs/Split", Width = 0.5f)]
[TabGroup("Tabs/Split/Parameters", "A")]
public string NameA, NameB, NameC;
[TabGroup("Tabs/Split/Parameters", "B")]
public int ValueA, ValueB, ValueC;
[TabGroup("Tabs/Split/Buttons", "Responsive")]
[ResponsiveButtonGroup("Tabs/Split/Buttons/Responsive/ResponsiveButtons")]
public void Hello() { }
[ResponsiveButtonGroup("Tabs/Split/Buttons/Responsive/ResponsiveButtons")]
public void World() { }
[ResponsiveButtonGroup("Tabs/Split/Buttons/Responsive/ResponsiveButtons")]
public void And() { }
[ResponsiveButtonGroup("Tabs/Split/Buttons/Responsive/ResponsiveButtons")]
public void Such() { }
[Button]
[TabGroup("Tabs/Split/Buttons", "More Tabs")]
[TabGroup("Tabs/Split/Buttons/More Tabs/SubTabGroup", "A")]
public void SubButtonA() { }
[Button]
[TabGroup("Tabs/Split/Buttons/More Tabs/SubTabGroup", "A")]
public void SubButtonB() { }
[Button(ButtonSizes.Gigantic)]
[TabGroup("Tabs/Split/Buttons/More Tabs/SubTabGroup", "B")]
public void SubButtonC() { }
完整示例代碼
using Sirenix.OdinInspector;
using System;
using UnityEngine;
public class TabGroupAttributeExample : MonoBehaviour
{
[TabGroup("Tab A")]
public int One;
[TabGroup("Tab A")]
public int Two;
[TabGroup("Tab A")]
public int Three;
[TabGroup("Tab B")]
public string MyString;
[TabGroup("Tab B")]
public float MyFloat;
[TabGroup("Tab C")]
[HideLabel]
public MyTabObject TabC;
[TabGroup("New Group", "Tab A")]
public int A;
[TabGroup("New Group", "Tab A")]
public int B;
[TabGroup("New Group", "Tab A")]
public int C;
[TabGroup("New Group", "Tab B")]
public string D;
[TabGroup("New Group", "Tab B")]
public float E;
[TabGroup("New Group", "Tab C")]
public MyTabObject F;
[Serializable]
public class MyTabObject
{
public int A;
public int B;
public int C;
}
[TitleGroup("Tabs")]
[HorizontalGroup("Tabs/Split", Width = 0.5f)]
[TabGroup("Tabs/Split/Parameters", "A")]
public string NameA, NameB, NameC;
[TabGroup("Tabs/Split/Parameters", "B")]
public int ValueA, ValueB, ValueC;
[TabGroup("Tabs/Split/Buttons", "Responsive")]
[ResponsiveButtonGroup("Tabs/Split/Buttons/Responsive/ResponsiveButtons")]
public void Hello() { }
[ResponsiveButtonGroup("Tabs/Split/Buttons/Responsive/ResponsiveButtons")]
public void World() { }
[ResponsiveButtonGroup("Tabs/Split/Buttons/Responsive/ResponsiveButtons")]
public void And() { }
[ResponsiveButtonGroup("Tabs/Split/Buttons/Responsive/ResponsiveButtons")]
public void Such() { }
[Button]
[TabGroup("Tabs/Split/Buttons", "More Tabs")]
[TabGroup("Tabs/Split/Buttons/More Tabs/SubTabGroup", "A")]
public void SubButtonA() { }
[Button]
[TabGroup("Tabs/Split/Buttons/More Tabs/SubTabGroup", "A")]
public void SubButtonB() { }
[Button(ButtonSizes.Gigantic)]
[TabGroup("Tabs/Split/Buttons/More Tabs/SubTabGroup", "B")]
public void SubButtonC() { }
}