Version: 2021.3
言語: 日本語

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 { }

Did you find this page useful? Please give it a rating: