[BurstCompile]
public static class TestUtil
{
[BurstCompile]
public static int3 ItDoesntWork()
{
return int3.zero;
}
[BurstCompile]
public static int3 ItWorksWithGeneric<T>()
{
return int3.zero;
}
}
Only the first method generates an error while compile the job : “Burst error BC1064: Unsupported return type Unity.Mathematics.int3”.
When my method use a generic, I don’t have an error. Why ?
In my code, I have a lot of static methods that return structs. Should I avoid this ? What are the consequences ?
The second one doesn’t “work.” Each entry point is compiled to one method, so what type argument should it use? The answer is “you can’t choose,” so it shouldn’t be compiled as a Burst entry point. You can check it yourself in the Burst Inspector, the method shouldn’t be there. Calling that method from other Bursted code will be Burst-compiled since you have a known type argument, and managed code calling the method will only be calling the original, managed method.
I didn’t understant that there was a difference if the method was called from other Bursted code or from managed code.
I’m still surprised that the method with the generic doesn’t cause at least a warning.