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 RequiredAttribute : Attribute, _Attribute
Required is used on any object property, and draws a message in the inspector if the property is missing.
Use this to clearly mark fields as necessary to the object.
The following example shows different uses of the Required attribute.
public class MyComponent : MonoBehaviour
{
[Required]
public GameObject MyPrefab;
[Required(InfoMessageType.Warning)]
public Texture2D MyTexture;
[Required("MyMesh is nessessary for this component.")]
public Mesh MyMesh;
[Required("MyTransform might be important.", InfoMessageType.Info)]
public Transform MyTransform;
}
public RequiredAttribute()
public RequiredAttribute(InfoMessageType messageType)
InfoMessageType | messageType | The type of info box to draw. |
public RequiredAttribute(string errorMessage)
System.String | errorMessage | The message to display in the error box. |
public RequiredAttribute(string errorMessage, InfoMessageType messageType)
System.String | errorMessage | The message to display in the error box. |
InfoMessageType | messageType | The type of info box to draw. |
public string ErrorMessage
public InfoMessageType MessageType