Version: 2020.2
언어: 한국어

BurstDiscardAttribute

class in Unity.Burst

매뉴얼로 전환

설명

The BurstDiscard attribute lets you remove a method or property from being compiled to native code by the burst compiler.

By default, a job compiled with burst will compile all methods. In some cases, you could have managed methods that cannot be compiled to native (e.g checking for validity only valid in a managed environment or logging using managed objects...etc) and should not be executed at runtime. In that case you can use this attribute to mark a method or property as not compilable by the burst compiler.

using Unity.Burst;
using Unity.Collections;
using Unity.Jobs;
using UnityEngine;

public struct MyJob : IJob { // ...

[BurstDiscard] public void NotExecutedInNative() { Debug.Log("This is a log from a managed job"); }

public void Execute() { // The following method call will not be compiled NotExecutedInNative(); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961