PreviewFieldAttribute

Draws a square ObjectField which renders a preview for UnityEngine.Object types. This object field also adds support for drag and drop, dragging an object to another square object field, swaps the values. If you hold down control while letting go it will replace the value, And you can control + click the object field to quickly delete the value it holds.

These object fields can also be selectively enabled and customized globally from the Odin preferences window.

namespace Sirenix.OdinInspector
{
[AttributeUsageAttribute((AttributeTargets)384, AllowMultiple = False, Inherited = True)]
public class PreviewFieldAttribute : Attribute
}

Requirements

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector
Version: 1.0.6.1

See Also

Constructors

Definition Description
PreviewFieldAttribute() Draws a square object field which renders a preview for UnityEngine.Object type objects.
PreviewFieldAttribute(float) Draws a square object field which renders a preview for UnityEngine.Object type objects.
PreviewFieldAttribute(float, ObjectFieldAlignment) Draws a square object field which renders a preview for UnityEngine.Object type objects.
PreviewFieldAttribute(ObjectFieldAlignment) Draws a square object field which renders a preview for UnityEngine.Object type objects.

Properties

Return Type Definition Description
ObjectFieldAlignment Alignment Left aligned.
bool AlignmentHasValue Whether an alignment value is specified.
float Height The height of the object field

Example

The following example shows how PreviewField is applied to a few property fields.

public MyComponent : MonoBehaviour
{
	[PreviewField]
	public UnityEngine.Object SomeObject;
	
	[PreviewField]
	public Texture SomeTexture;

	[HorizontalGroup, HideLabel, PreviewField(30)]
	public Material A, B, C, D, F;
}