Inline Editor Attribute

InlineAttribute is used on any property or field with a type that inherits from UnityEngine.Object. This includes components and assets etc.

[InlineEditor]
public ExampleTransform InlineComponent;

[InlineEditor(InlineEditorModes.FullEditor)]
public Material FullInlineEditor;

[InlineEditor(InlineEditorModes.GUIAndHeader)]
public Material InlineMaterial;

[InlineEditor(InlineEditorModes.SmallPreview)]
public Material[] InlineMaterialList;

[InlineEditor(InlineEditorModes.LargePreview)]
public Mesh InlineMeshPreview;

// You can also use the InlineEditor attribute directly on a class definition itself!
//[InlineEditor]
//public class ExampleTransform : ScriptableObject
//{
//    public Vector3 Position;
//    public Quaternion Rotation;
//    public Vector3 Scale = Vector3.one;
//}

[OnInspectorInit]
private void CreateData()
{
    InlineComponent = ExampleHelper.GetScriptableObject<ExampleTransform>("Inline Component");
    FullInlineEditor = ExampleHelper.GetMaterial();
    InlineMaterial = ExampleHelper.GetMaterial();
    InlineMaterialList = new Material[]
    {
        ExampleHelper.GetMaterial(),
        ExampleHelper.GetMaterial(),
        ExampleHelper.GetMaterial(),
    };
    InlineMeshPreview = ExampleHelper.GetMesh();
}

[OnInspectorDispose]
private void CleanupData()
{
    if (InlineComponent != null) Object.DestroyImmediate(InlineComponent);
}

[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")]
[InlineEditor(InlineEditorObjectFieldModes.Hidden)]
public ExampleTransform OnlyHiddenWhenNotNull;

[OnInspectorInit]
private void CreateData()
{
    Boxed = ExampleHelper.GetScriptableObject<ExampleTransform>("Boxed");
    Foldout = ExampleHelper.GetScriptableObject<ExampleTransform>("Foldout");
    CompletelyHidden = ExampleHelper.GetScriptableObject<ExampleTransform>("Completely Hidden");
    OnlyHiddenWhenNotNull = ExampleHelper.GetScriptableObject<ExampleTransform>("Only Hidden When Not Null");
}

[OnInspectorDispose]
private void CleanupData()
{
    if (Boxed != null) Object.DestroyImmediate(Boxed);
    if (Foldout != null) Object.DestroyImmediate(Foldout);
    if (CompletelyHidden != null) Object.DestroyImmediate(CompletelyHidden);
    if (OnlyHiddenWhenNotNull != null) Object.DestroyImmediate(OnlyHiddenWhenNotNull);
}