Version: 2022.3
言語: 日本語

RequireImplementorsAttribute

class in UnityEngine.Scripting

マニュアルに切り替える

説明

When the interface type is marked, all types implementing that interface will be marked.

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 {}
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961