Version: 2023.1
언어: 한국어

RequireAttributeUsagesAttribute

class in UnityEngine.Scripting

매뉴얼로 전환

설명

Only allowed on attribute types. If the attribute type is marked, then so too will all CustomAttributes of that type.

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

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 remove class Foo { }

class TypeUsedAttribute : Attribute { }

[RequireAttributeUsages] class RequiredAttribute : Attribute { }

class UnusedAndNotRequiredAttribute : Attribute { }