Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


RequireAttributeUsagesAttribute

Only allowed on attribute types. If the attribute type is marked, then so too will all CustomAttributes of that type.
Read time 3 minutesLast updated 5 days ago

Definition

[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]public class RequireAttributeUsagesAttribute : Attribute

Remarks

Note that Low and Medium Managed Stripping Levels do not remove any CustomAttributes.

Examples

using System;using UnityEngine;using UnityEngine.Scripting;public class NewBehaviourScript : MonoBehaviour{ void Start() { var f = new Foo(); foreach (var attr in f.GetType().CustomAttributes) { if (attr.AttributeType == typeof(TypeUsedAttribute)) { Debug.Log(attr.AttributeType); } } }}[TypeUsed] // Will survive because TypeUsedAttribute is used[Required] // Will survive because RequiredAttribute has the attribute [RequireAttributeUsages][UnusedAndNotRequiredAttribute] // Is considered valid for managed code stripping to removeclass Foo{}class TypeUsedAttribute : Attribute{}[RequireAttributeUsages]class RequiredAttribute : Attribute{}class UnusedAndNotRequiredAttribute : Attribute{}

Inheritance

Inherited Members