Search Unity

Question 0.51 upgrade to 1.0.0-prev15

Discussion in 'Graphics for ECS' started by sstrong, Mar 12, 2023.

  1. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,252
    Is there a migration guide from Entities 0.51 to 1.0.0?

    For example, I'm trying to understand what I need to do with converting my worldspace position and rotation to the new Transforms components (all my calculations are currently in WS). Do I need to add a WorldTransform component (rather than individual Translation and Rotation components?

    Code (CSharp):
    1. Entity entity = entityManager.Instantiate(projectilePrefabEntity);
    2. ..
    3.  
    4. // Set their position, rotation and projectile properties
    5. // Shift the position forward by the weapon velocity, so that projectiles don't ever end up behind the ship
    6. entityManager.SetComponentData(entity, new Translation() { Value = (float3)position + (_velocity * deltaTime) });
    7. entityManager.SetComponentData(entity, new Rotation() { Value = quaternion.LookRotation(startFwdDirection, startUpDirection) });
    8. ..
    I'm assuming I need to do something like the following, but not sure.
    Code (CSharp):
    1. #if UNITY_2022_2_OR_NEWER
    2. // Set position from world origin
    3. LocalTransform localTrfm = entityManager.GetComponentData<LocalTransform>(entity);
    4. localTrfm.Position = (float3)position + (_velocity * deltaTime);
    5. localTrfm.Rotation = quaternion.LookRotation(startFwdDirection, startUpDirection);
    6. entityManager.SetComponentData<LocalTransform>(entity, localTrfm);
    7. #else
    8. entityManager.SetComponentData(entity, new Translation() { Value = (float3)position + (_velocity * deltaTime) });
    9. entityManager.SetComponentData(entity, new Rotation() { Value = quaternion.LookRotation(startFwdDirection, startUpDirection) });
    10. #endif
    Also, I have some ScheduleParallel IJobChunk jobs using a class derived from SystemBase. Should I now be using a struct derived from ISystem? Are there any conversion guidelines for this?

    EDIT: FOUND THIS
    Upgrading from Entities 0.51 to 1.0 | Entities | 1.0.0-pre.47 (unity3d.com)
     
    Last edited: Mar 12, 2023