Hello,
I’m working on logs for our game, and during my test, I found that statics FixedStringXBytes
throw errors when using them inside a [BurstCompile]
method (we’re using DOTS).
But the error only occurs when using a static FixedStringXBytes
and not a local one, nor a static primitive type like int
. So, how Burst does work for static non-primitive types and why does not this work?
[BurstCompile]
public partial struct Test : ISystem
{
public static readonly FixedString32Bytes StringTest = "Does not work";
public static readonly int IntTest = 1;
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
FixedString32Bytes stringTest = "Does work";
Debug.Log($"This is ok {stringTest}");
Debug.Log($"This is ok {IntTest}");
/* Burst error BC0102: Unexpected internal compiler error while
* processing function `IL_0041: ldflda Unity.Collections.FixedString32Bytes
* Simulation.ECS.Systems.Test::StringTest`: System.NullReferenceException:
* Object reference not set to an instance of an object
* at Burst.Compiler.IL.Syntax.ILInstruction+ArgumentList.get_Item
*/
Debug.Log($"This throws an error {StringTest}");
}
}
Thank you