DevNotes_190206
using Sirenix.OdinInspector;
[ShowIf(“一个bool变量的名字”)]
可以选择是否显示
[MinValue(0)]
[MaxValue(100)]
不能大于
[Wrap(0,100)]
限制在之内
[MinMaxSlider(0,100)]可以用来表示二维向量;
[ProgressBar(0,10)]
进度条
带颜色的进度条:
[ProgressBar(0,100,ColorMember = “ChangeColor:)]
public float hpBar;
public Color ChangeColor(float value)
{
return Color.Lerp(Color.red, Color.green, MathUtilities.LinearStep(0,100,value));
}
Enum 扩展:
[EnumToogleButtons]
让枚举可以直接点击来选择
List 扩展:
(Odin自带高级显示)
[ListDrawerSettings(NumberOfItemsPerPage = 5)]
按页显示
Dictionary 扩展:
需要将MonoBehavior更改为SerializableMonoBehaviour
(Odin自带高级显示)
[Title(“这里可以是个标题)]
[FoldoutGroup(“这里可以是个折叠的名字”)] 这个要给每个字段前面都要加
一个类
[CustomEditor(typeof(那边那个类的名字))] (此处那个类是 OdinTest
继承OdinEditor
private OdinTest ——odinTest{ get { return target as OdinTest; }}
public override void OnInspectorGUI(){
base.OnInspectorGUI();
int selectIndex = 0 ;
for( int i = 0; i< _odinTest.stringList.Count; i++)
{
if( _odinTest.selectString == _odinTest.stringList[i]
{
selectIndex = i;
break;
}
selectIndex = EditorGUILayout.Popup(“SelectString”,selectIndex,_odinText.stringList.ToArraay());
_odinTest.selectString = _odinTest.stringList[selectIndex];
}