기술 자료

Unity Engine

Download Unity

Unity Engine

RequireAttributeUsagesAttribute

Only allowed on attribute types. If the attribute type is marked, then so too will all CustomAttributes of that type.
읽는 시간 3분최근 업데이트: 2달 전

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