Class BurstCompileAttribute
This attribute can be used to tag jobs as being Burst Compiled, and optionally set some compilation parameters.
Inheritance
Namespace: Unity.Burst
Syntax
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method)]
public class BurstCompileAttribute : Attribute, _Attribute
Constructors
BurstCompileAttribute()
Tags a struct/method/class as being burst compiled, with the default FloatPrecision, FloatMode and CompileSynchronously.
Declaration
public BurstCompileAttribute()
Examples
[BurstCompile]
struct MyMethodsAreCompiledByBurstUsingTheDefaultSettings
{
//....
}
BurstCompileAttribute(FloatPrecision, FloatMode)
Tags a struct/method/class as being burst compiled, with the specified FloatPrecision, FloatMode and the default CompileSynchronously.
Declaration
public BurstCompileAttribute(FloatPrecision floatPrecision, FloatMode floatMode)
Parameters
Type | Name | Description |
---|---|---|
FloatPrecision | floatPrecision | Specify the required floating point precision. |
FloatMode | floatMode | Specify the required floating point mode. |
Examples
[BurstCompile(FloatPrecision.Low,FloatMode.Fast)]
struct MyMethodsAreCompiledByBurstWithLowPrecisionAndFastFloatingPointMode
{
//....
}
Properties
CompileSynchronously
Gets or sets whether or not to burst compile the code immediately on first use, or in the background over time.
Declaration
public bool CompileSynchronously { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | The default is false, true will force this code to be compiled synchronously on first invocation. |
Debug
Gets or sets whether to compile the code in a way that allows it to be debugged. If this is set to
true
, the current implementation skips compilation of this method
so that the original .NET method can be debugged.
In the current implementation, this property is only used in the Editor and ignored for standalone players.
Declaration
public bool Debug { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | The default is .
|
FloatMode
Gets or sets the float mode of operation for this burst compilation.
Declaration
public FloatMode FloatMode { get; set; }
Property Value
Type | Description |
---|---|
FloatMode | The default is Default. |
FloatPrecision
Gets or sets the floating point precision to use for this burst compilation. Allows you to trade accuracy for speed of computation, useful when you don't require much precision.
Declaration
public FloatPrecision FloatPrecision { get; set; }
Property Value
Type | Description |
---|---|
FloatPrecision | The default is Standard. |