How can use UnityEngine.Debug.Log in Burst?

Like this , runtime show error :
E:\fzy\DOTS\EntityComponentSystemSamples-master\ECSSamples\Assets\a-MyDots\02-Wander\WanderSystem.cs(20,5): Burst error BC1020: Boxing a valuetype float to a managed object is not supported.
If I remove UnityEngine.Debug.Log(angle) there is not error

    protected override void OnUpdate()
    { 
        float deltaTime = Time.DeltaTime;
        Entities.WithBurst(FloatMode.Default, FloatPrecision.Standard, true).ForEach((ref Translation trans, ref WanderComponent com) => {
            if (!com.isSignDest)
            {
                com.isSignDest = true;
                com.isArriveDest = false;
                var random = new Random((uint)((trans.Value.x * 1000f % 1000f) + 1));
                float angle = random.NextFloat(0f, 180f);
                UnityEngine.Debug.Log(angle);
                float rad = math.degrees(angle);
                float x = com.radius * math.cos(rad);
                float z = com.radius * math.sin(rad);
                com.dest = math.float3(x, 0, z);
            }

            if (com.isSignDest && !com.isArriveDest)
            {
                trans.Value += math.normalize((com.dest - trans.Value)) * com.speed * deltaTime;
                if (math.abs(math.distance(trans.Value, com.dest)) <= 0.001f)
                {
                    com.isSignDest = false;
                    com.isArriveDest = true;
                }
            }
        }).ScheduleParallel();
    }

Which version of burst are you using ?

https://docs.unity3d.com/Packages/com.unity.burst@1.3/manual/index.html#partial-support-for-strings-and-debuglog

try
Debug.Log($"{angle}");

it’s ok now. thank you. it need to upgrade burst to 1.3.9

1 Like