InlineAttribute用于任何屬性或字段,其類型繼承自UnityEngine.Object岩馍。這包括組件和資產(chǎn)等鳖目。
【InlineEditorObjectFieldModes.Boxed】屬性以Box形式展示
[Title("Boxed / Default")]
[InlineEditor(InlineEditorObjectFieldModes.Boxed)]
public ExampleTransform Boxed;
【InlineEditorObjectFieldModes.Foldout】屬性以折頁形式展示
[Title("Foldout")]
[InlineEditor(InlineEditorObjectFieldModes.Foldout)]
public ExampleTransform Foldout;
【InlineEditorObjectFieldModes.CompletelyHidden】隱藏屬性名稱
[Title("Hide ObjectField")]
[InlineEditor(InlineEditorObjectFieldModes.CompletelyHidden)]
public ExampleTransform CompletelyHidden;
【InlineEditorObjectFieldModes.Hidden】只有為null的時候才顯示字段
[Title("Show ObjectField if null")]
[ShowInInspector]
[InlineEditor(InlineEditorObjectFieldModes.Hidden)]
public ExampleTransform OnlyHiddenWhenNotNull;
4預(yù)覽模式
【InlineEditorModes.FullEditor】
[InlineEditor(InlineEditorModes.FullEditor)]
public Material FullInlineEditor;
【InlineEditorModes.GUIAndHeader】
[InlineEditor(InlineEditorModes.GUIAndHeader)]
public Material InlineMaterial ;
【InlineEditorModes.SmallPreview】
[InlineEditor(InlineEditorModes.SmallPreview)]
public Material[] InlineMaterialList = new Material[]
{
};
【InlineEditorModes.LargePreview】
[InlineEditor(InlineEditorModes.LargePreview)]
public Mesh InlineMeshPreview ;
完整示例代碼
using Sirenix.OdinInspector;
using UnityEngine;
public class InlineEditorAttributeExample : MonoBehaviour
{
[Title("Boxed / Default")]
[InlineEditor(InlineEditorObjectFieldModes.Boxed)]
public ExampleTransform Boxed;
[Title("Foldout")]
[InlineEditor(InlineEditorObjectFieldModes.Foldout)]
public ExampleTransform Foldout;
[Title("Hide ObjectField")]
[InlineEditor(InlineEditorObjectFieldModes.CompletelyHidden)]
public ExampleTransform CompletelyHidden;
[Title("Show ObjectField if null")]
[ShowInInspector]
[InlineEditor(InlineEditorObjectFieldModes.Hidden)]
public ExampleTransform OnlyHiddenWhenNotNull;
[InlineEditor]
public ExampleTransform InlineComponent ;
[InlineEditor(InlineEditorModes.FullEditor)]
public Material FullInlineEditor;
[InlineEditor(InlineEditorModes.GUIAndHeader)]
public Material InlineMaterial ;
[InlineEditor(InlineEditorModes.SmallPreview)]
public Material[] InlineMaterialList = new Material[]
{
};
[InlineEditor(InlineEditorModes.LargePreview)]
public Mesh InlineMeshPreview ;
}