Calling function a that uses Debug.Log inside bursted job is impossible?

I can use

Entities.ForEach()
{
reason = ...
Debug.Log($"Failed Reason: {reason}");
{

but I can’t use

Entities.ForEach()
{
reason = ...
LogFailedReason(reason);
}

void LogFailedReason(FailedReason reason)
{
    Debug.Log($"Failed Reason: {reason}");
}

Why? I don’t want to duplicate my Debug.Log everywhere

Entities.ForEach Lambda expression invokes 'LogFailedReason' on a xxxSystem which is a reference type. This is only allowed with .WithoutBurst() and .Run().

1 Like

You can make the method static (the system on which you are trying to call LogFailedReason is indeed a reference type).

2 Likes