Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

why show error:This is only supported when using .WithoutBurst() and .Run().

Discussion in 'Burst' started by fanzhengyong2015, Oct 9, 2020.

Thread Status:
Not open for further replies.
  1. fanzhengyong2015

    fanzhengyong2015

    Joined:
    May 30, 2019
    Posts:
    26
    Code (CSharp):
    1. using System;
    2. using Unity.Entities;
    3.  
    4. [GenerateAuthoringComponent]
    5. public class RotateSpeed1 : IComponentData
    6. {
    7.     public float speed;
    8. }
    Code (CSharp):
    1.     protected override void OnUpdate()
    2.     {
    3.         float deltaTime = Time.DeltaTime;
    4.  
    5.         Entities.
    6.             ForEach((ref Rotation rotation, in RotateSpeed1 rotateSpeed) => {
    7.                 rotation.Value = math.mul(
    8.                     math.normalize(rotation.Value),
    9.                     quaternion.AxisAngle(math.up(), rotateSpeed.speed * deltaTime));
    10.             }).ScheduleParallel();
    11. }
    The complete error is : :\fzy\DOTS\EntityComponentSystemSamples-master\ECSSamples\Assets\a-MyDots\RotateSpeedSystem.cs(12,3): error DC0023: Entities.ForEach uses managed IComponentData RotateSpeed1&. This is only supported when using .WithoutBurst() and .Run().

    I don't understand, I think am not modify RotateSpeed1 rotateSpeed and use in RotateSpeed1 rotateSpeed. Why error show : Entities.ForEach uses managed IComponentData RotateSpeed1&

    I try to moify my code to :
    Code (CSharp):
    1.         Entities.WithoutBurst().ForEach((ref Rotation rotation, in RotateSpeed1 rotateSpeed) => {
    2.             rotation.Value = math.mul(
    3.                 math.normalize(rotation.Value),
    4.                 quaternion.AxisAngle(math.up(), rotateSpeed.speed * deltaTime));
    5.         }).Run();
    Then , thers is not error
     
  2. fanzhengyong2015

    fanzhengyong2015

    Joined:
    May 30, 2019
    Posts:
    26
    OMG, I get. public class RotateSpeed1 : IComponentData
    I should modify to public struct RotateSpeed1 : IComponentData
     
Thread Status:
Not open for further replies.