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 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.
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;
}
public SuppressInvalidAttributeErrorAttribute()