Class BurstCompatibleAttribute
Documents and enforces (via generated tests) that the tagged method or property has to stay burst compatible.
Namespace: Unity.Collections
Syntax
public class BurstCompatibleAttribute : Attribute
Fields
CompileTarget
Specifies whether code should be Burst compiled for the player, editor, or both.
Declaration
public BurstCompatibleAttribute.BurstCompatibleCompileTarget CompileTarget
Field Value
Type | Description |
---|---|
BurstCompatibleAttribute.BurstCompatibleCompileTarget |
Remarks
When set to BurstCompatibleCompileTarget.Editor, the generated Burst compatibility code will be surrounded by #if UNITY_EDITOR to ensure that the Burst compatibility test will only be executed in the editor. The code will be compiled with Burst function pointers. If you have a non-null RequiredUnityDefine, an #if with the RequiredUnityDefine will also be emitted.
When set to BurstCompatibilityCompileTarget.Player, the generated Burst compatibility code will only be surrounded by an #if containing the RequiredUnityDefine (or nothing if RequiredUnityDefine is null). Instead of compiling with Burst function pointers, a player build is started where the Burst AOT compiler will verify the Burst compatibility. This is done to speed up Burst compilation for the compatibility tests since Burst function pointer compilation is not done in parallel.
When set to BurstCompatibilityCompileTarget.PlayerAndEditor, the generated Burst compatibility code will only be surrounded by an #if containing the RequiredUnityDefine (or nothing if RequiredUnityDefine is null). The code will be compiled both by the editor (using Burst function pointers) and with a player build (using Burst AOT).
For best performance of the Burst compatibility tests, prefer to use BurstCompatibilityCompileTarget.Player as much as possible.
RequiredUnityDefine
Specifies the symbol that must be defined in order for the method to be tested for Burst compatibility.
Declaration
public string RequiredUnityDefine
Field Value
Type | Description |
---|---|
String |
Properties
GenericTypeArguments
Types to be used for the declared generic type or method.
Declaration
public Type[] GenericTypeArguments { get; set; }
Property Value
Type | Description |
---|---|
Type[] |
Remarks
The generic type arguments are tracked separately for types and methods. Say a generic type also contains a generic method, like in the case of Foo<T>.Bar<U>(T baz, U blah). You must specify GenericTypeArguments for Foo and also for Bar to establish the concrete types for T and U. When code generation occurs for the Burst compatibility tests, any time T appears (in the definition of Foo) it will be replaced with the generic type argument you specified for Foo and whenever U appears (in method Bar's body) it will be replaced by whatever generic type argument you specified for the method Bar.