Version 2.1.0.0

Odin has a dedicated attribute overview with examples

SuppressInvalidAttributeErrorAttribute class

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)]
public sealed class SuppressInvalidAttributeErrorAttribute : Attribute, _Attribute

SuppressInvalidAttributeError is used on members to suppress the inspector error message you get when applying an attribute to a value that it's not supposed to work on.

This can be very useful for applying attributes to generic parameter values, when it only applies to some of the possible types that the value might become.

Inheritance
  • System.Object
  • System.Attribute
  • SuppressInvalidAttributeErrorAttribute
Example

The following example shows a case where the attribute might be useful.

public class NamedValue<T>
{
    public string Name;

    // The Range attribute will be applied if T is compatible with it, but if T is not compatible, an error will not be shown.
	[SuppressInvalidAttributeError, Range(0, 10)]
	public T Value;
}

Constructors

SuppressInvalidAttributeErrorAttribute()
public SuppressInvalidAttributeErrorAttribute()

This website is brand new and built with the Odin 2.1 beta in mind. This means you might discover some features such as attribute expressions that are only available in the beta.

You can download the 2.1 beta from here and read the patch-notes here.