Namespace: | Sirenix.OdinInspector |
Assembly: | Sirenix.OdinInspector.Attributes |
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter | AttributeTargets.All, AllowMultiple = false, Inherited = true)]
[Conditional("UNITY_EDITOR")]
public class PreviewFieldAttribute : Attribute, _Attribute
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.
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;
}
public PreviewFieldAttribute()
public PreviewFieldAttribute(ObjectFieldAlignment alignment)
ObjectFieldAlignment | alignment | The alignment of the preview field. |
public PreviewFieldAttribute(float height)
System.Single | height | The height of the preview field. |
public PreviewFieldAttribute(float height, ObjectFieldAlignment alignment)
System.Single | height | The height of the preview field. |
ObjectFieldAlignment | alignment | The alignment of the preview field. |
public PreviewFieldAttribute(string previewGetter, ObjectFieldAlignment alignment, FilterMode filterMode)
System.String | previewGetter | A resolved value that should resolve to the desired preview texture. |
ObjectFieldAlignment | alignment | The alignment of the preview field. |
UnityEngine.FilterMode | filterMode | The filter mode to be used for the preview texture. |
public PreviewFieldAttribute(string previewGetter, float height, ObjectFieldAlignment alignment, FilterMode filterMode)
System.String | previewGetter | A resolved value that should resolve to the desired preview texture. |
System.Single | height | The height of the preview field. |
ObjectFieldAlignment | alignment | The alignment of the preview field. |
UnityEngine.FilterMode | filterMode | The filter mode to be used for the preview texture. |
public PreviewFieldAttribute(string previewGetter, float height, FilterMode filterMode)
System.String | previewGetter | A resolved value that should resolve to the desired preview texture. |
System.Single | height | The height of the preview field. |
UnityEngine.FilterMode | filterMode | The filter mode to be used for the preview texture. |
public PreviewFieldAttribute(string previewGetter, FilterMode filterMode)
System.String | previewGetter | A resolved value that should resolve to the desired preview texture. |
UnityEngine.FilterMode | filterMode | The filter mode to be used for the preview texture. |
public FilterMode FilterMode
public float Height
public ObjectFieldAlignment Alignment { get; set; }
public bool AlignmentHasValue { get; }
public string PreviewGetter { get; set; }
public bool PreviewGetterHasValue { get; }