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

RequireImplementorsAttribute

класс в UnityEngine.Scripting

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

Описание

Когда помечен тип интерфейса, помечаются все типы, реализующие этот интерфейс.

using System;
using UnityEngine;
using UnityEngine.Scripting;

public class NewBehaviourScript : MonoBehaviour { void Start() { IFoo ifoo = new Foo(); } }

[RequireImplementors] interface IFoo {}

class Foo : IFoo {}

// UnusedFoo is not used, however, it will survive managed code stripping due to IFoo having the [RequireImplementors] attribute. class UnusedFoo : IFoo { // Note that unused members of UnusedFoo will still be removed by managed code stripping public static void UnusedMethod() {} }

// IBar is not used so it will be removed by managed code stripping [RequireImplementors] interface IBar {}

// Because IBar is not used, the [RequireImplementors] attribute on IBar has no impact. UnusedBar will also be removed. class UnusedBar : IBar {}