TypeInfoBox特性:將信息框添加到Inspector中類型的最頂部。
使用此選項可將信息框添加到Inspector中類的頂部,而無需同時使用PropertyOrder和OnInspectorGUI屬性。
完整示例代碼
TypeInfoBoxExample
using Sirenix.OdinInspector;
using System;
using UnityEngine;
public class TypeInfoBoxExample : MonoBehaviour
{
public MyType MyObject = new MyType();
[InfoBox("雙擊此此段的value值,可在inspecter中查看對應(yīng)ScriptableObject信息")]
public MyScripty Scripty = null;
public void Awake()
{
Scripty = ExampleHelper.GetScriptableObject<MyScripty>();
}
[Serializable]
[TypeInfoBox("TypeInfoBox特性可以放在類型定義上,并將導(dǎo)致在屬性的頂端處繪制一個InfoBox。")]
public class MyType
{
public int Value;
}
}
MyScripty
using Sirenix.OdinInspector;
using UnityEngine;
[CreateAssetMenu(fileName = "MyScripty_ScriptableObject", menuName = "CreatScriptableObject/MyScripty", order = 100)]
[TypeInfoBox("TypeInfoBox 特性 能以文本的形式顯示在頂端 。例如, MonoBehaviours or ScriptableObjects.")]
public class MyScripty : ScriptableObject
{
public string MyText = ExampleHelper.GetString();
[TextArea(10, 15)]
public string Box;
}