Inline Editor 特性用于类型继承自 UnityEngine.Object 的任何属性或字段;包括组件和资产等。
示例展示
一.内联编辑器模式
1.【InlineEditorObjectFieldModes.Boxed】属性以Box形式展示
[Title("Boxed / Default")]
[InlineEditor(InlineEditorObjectFieldModes.Boxed)]
public ExampleTransform Boxed;
2.【InlineEditorObjectFieldModes.Foldout】属性以折页形式展示
[Title("Foldout")]
[InlineEditor(InlineEditorObjectFieldModes.Foldout)]
public ExampleTransform Foldout;
3.【InlineEditorObjectFieldModes.CompletelyHidden】隐藏属性名称
[Title("Hide ObjectField")]
[InlineEditor(InlineEditorObjectFieldModes.CompletelyHidden)]
public ExampleTransform CompletelyHidden;
4.【InlineEditorObjectFieldModes.Hidden】只有为null的时候才显示字段
[Title("Show ObjectField if null")]
[ShowInInspector]
[InlineEditor(InlineEditorObjectFieldModes.Hidden)]
public ExampleTransform OnlyHiddenWhenNotNull;
二.预览模式
1.【InlineEditorModes.FullEditor】
[InlineEditor(InlineEditorModes.FullEditor)]
public Material FullInlineEditor;
2.【InlineEditorModes.GUIAndHeader】
[InlineEditor(InlineEditorModes.GUIAndHeader)]
public Material InlineMaterial ;
3.【InlineEditorModes.SmallPreview】
[InlineEditor(InlineEditorModes.SmallPreview)]
public Material[] InlineMaterialList = new Material[]
{
};
4.【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 ;
}