Unity 6.3
0 онлайн 67 гостей 3 в системе
Вход

RequireAttributeUsagesAttribute

класс в UnityEngine.Scripting

Выполнено в:UnityEngine.CoreModule

Описание

Разрешено только для типов атрибутов. Если тип атрибута отмечен, то все CustomAttributes этого типа также будут отмечены.

Обратите внимание, что низкие и средние управляемые уровни удаления не удаляют 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 { }