Search Unity

Official New version of Entities 1.0 pre-release now available - March 2023

Discussion in 'Entity Component System' started by IsaacsUnity, Mar 22, 2023.

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

    IsaacsUnity

    Unity Technologies

    Joined:
    Mar 1, 2022
    Posts:
    94
    Hello everyone! We’ve just published a new version of Entities and other ECS-based packages compatible with Unity 2022.2 Tech Stream.

    Getting started
    If you are just getting started, refer to our installation and setup guide in our documentation to help with project setup. We recommend using these packages with Unity 2022.2.10f1 and above. You can find the changelog for the latest editor version here.

    We also have the following samples and documentation available for you to get started quickly:
    • Experimental Character Controller package: For users looking to quickly jump into building their game, the Experimental Character Controller package is available and compatible with the pre-release of ECS for Unity, including documentation and implementation samples.
    • DOTS Guide, ECS Samples, and Learn Content: Resources that are especially useful for new users to learn about fundamental concepts of data-oriented design.
    • ECS Network Racing: A multiplayer racing sample showcasing the capabilities of Netcode for Entities and how you can easily build a multiplayer game out of the box. This sample exemplifies an implementation of client/server architecture with client-side prediction, interpolation, and lag compensation.
    • Megacity: A sample showcasing how you can stream thousands of entities into the game scene at a stable 60 FPS, with thousands of active physics colliders and dynamic vehicles actively performing collision avoidance.
    Please note that we're in the midst of updating some of our samples to reflect the latest changes to the Transform System from this release.

    Notable Highlights
    Here are some of the notable highlights from this release. For a full list of changes in each package, refer to the changelogs in our documentation (linked below):
    • Entities
      • Updated Transform System:
        • Simplified transform system with fewer components and systems, including WorldTransform and ParentTransform.
        • TransformUsageFlags are now available at bake-time, allowing users to use a minimal set of components and achieve further optimization.
        • Removed ENABLE_TRANSFORM_V1 and TransformAspect.
      • Refactored how additive scenes are handled within the Runtime Content Manager.
      • IJobEntity no longer gives a compile error if you have a reference type field. This improves iteration time and has the added benefit that you can now write managed code in an IJobEntity.
    • Collections
      • Added performance comparisons between different allocator types and comparisons between containers running across combinations of Mono, Job Safety Checks and Burst in the package documentation.
      • Improved performance of job safety checks in containers when code is not Burst compiled.
    • Entities Graphics (Editor fixes)
      • Fixed an issue where lightmaps involving lights inside subscenes could be too bright.
      • Fixed BatchRendererGroup occlusion probe sampling for HDRP.
    • Unity Physics
      • Physics Debug Display for enabled Collider Edges now draws correctly if the collider scale is modified during runtime.
      • Debug display systems no longer stall and instead execute their jobs asynchronously.
      • Debug draw of collider faces and AABBs now account for uniform scaling of the rigid body.
      • Rigidbody components that move in PlayMode will now correctly snap back to their original position when exiting PlayMode while the containing SubScene is open for editing.
    • Havok Physics for Unity
      • Havok Visual Debugger (VDB) now works correctly on 12th Gen and later Intel® Core™ devices.
    • Netcode for Entities
      • Removed the “Component” suffix to all the public-facing Netcode components and buffers (Script AutoUpdater will automatically fix the API).
      • GhostComponent renamed GhostInstance (Script AutoUpdater will automatically fix the API).
      • SharedGhostTypeComponent renamed GhostTypePartition (Script AutoUpdater will automatically fix the API).
      • Fixed an issue with the source generator, validating incorrectly custom templates that use overrides.
      • Fixed an issue with the source generator throwing an exception while validating the required ASM dependencies and removed Unity.Networking.Transport dependency.
      • Fixed a rare exception in GhostColletion, when processing predicted ghost prefabs.
      • Fixed an issue in GhostUpdateSystem where the system tries to use an invalid interpolation tick.
      • Avoid throwing exceptions in the player build when the send queue is full.
    Runtime authoring with ECS for Unity
    We've also just published a Tech From the Trenches blog post diving into Data Modes, which helps you manage the duality of Authoring Data and Runtime Data while working with ECS for Unity. Do check it out and let us know what you think.

    Sharing feedback
    This forum is the best place to open discussions and ask questions.
    • If you encounter a bug, please use the Unity Bug Reporter in the Unity Editor, accessible via Help > Report a Bug. Include the name of the package (with version number) in the title to help our team triage things appropriately.
    • To learn more about what we are working on, you can refer to this post and our public roadmap where you can share feedback and submit ideas.
    Thank you again to everyone who has continued to take the time to share feedback. We look forward to hearing from you!
     
  2. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,685
  3. IsaacsUnity

    IsaacsUnity

    Unity Technologies

    Joined:
    Mar 1, 2022
    Posts:
    94
    eizenhorn likes this.
  4. Laicasaane

    Laicasaane

    Joined:
    Apr 15, 2015
    Posts:
    361
    What is the cons of managed code inside IJobEntity we should be aware of?
     
  5. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,685
    Glad to hear you too! With serializing managed components in subscene we probably closer to migrate to 1.0.0 from 0.51 with Diplomacy is Not an Option :) Maybe passing custom context to SystemAPI also will be released soon for allowing usage in static context? :D
     
    Last edited: Mar 23, 2023
    Sirius64 and Laicasaane like this.
  6. DaxodeUnity

    DaxodeUnity

    Unity Technologies

    Joined:
    Aug 5, 2021
    Posts:
    27
    Glad you asked!

    There is a few, first is fairly obvious. Burst doesn't work. It's managed and so it can't be.

    Now comes the interesting bits. So the JobSystem will throw an error your way at runtime if you have a managed field in a job. That's a fact of the JobSystem. This doesn't mean you can't access managed data in a job. It just means you can't have a field in a job. It also means we discourage it. We discourage it because we can't make any safety guarantees. You could get the managed reference through statics. Or you could get it through a GCHandle (which could be stored as field). The guard rails are off so make you're playing by the rules of race-conditions, false-sharing etc. There's a lot of power in this, *insert marvel quote here*.

    That's the gotcha. Then there's also the fact that most UnityEngine objects are protected for mainthread only and will explicitly complain at you.

    For how to use the GCHandle, here's an example:
    https://coffeebraingames.wordpress.com/2019/03/17/run-managed-code-in-unitys-job-system/

    We also want to encourage the use of burst. As an example say you wanted a job to figure out the closest GameObject to your GO laser turret. And shoot at the GO. The job doesn't need to actually do the shooting. It just needed to find the closest object. And so if you had a store that stored that info then you could pass a Native collection to the job with a bunch of float3 points and an int indicating the pointer into that store. And so when you come out of the job you just lookup the int and get the GO. Now laser.Shoot(LaserTargetStore[resultOfJob]).

    There's also specific IJobEntity parts here.
    IJobEntity does allow managed components as part of the Execute signature. When you do this, you say 'I accept no longer being able to Schedule/ScheduleParallel this job.' You will get a runtime error for trying. To make this work for UnityEngine.Transform and similar (due to the aforementioned UnityEngine restriction) we turn off the JobSystem for the job. But oh no! How could we do that? Well, for one you were the one to add a managed component and so you already expected to not be able to burst it. And so we don't have to either. This means we can call the function directly. Also another power of the JobSystem is that it will pre-error. If you didn't setup a TypeHandle it will yell at you at schedule time instead of when you're trying to use it. However IJobEntity, all the handles are setup for you and so they already are known to be correctly setup. This leaves any container you pass in as the main source of error. This we sadly don't detect, and so you'll get errors at runtime when trying to use them, and not at scheduling time.

    You might ask: Does "We turn off the JobSystem for any IJobEntity using managed components" then also mean my managed field in an IJobEntity will work when a managed component is present?
    The answer is yes. It's a byproduct of the solution. Use with care. It's not likely to cause issues, but it's definitely something that will make a newcomer ask "why does removing this unused component make the job fail".
     
  7. Laicasaane

    Laicasaane

    Joined:
    Apr 15, 2015
    Posts:
    361
    Thanks for your explanation. I think this piece of info should have a place on the Entities documentation, inside a warning text box. Please add this to the document if it's not there yet.
     
  8. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,164
    Well, I don't see any benefit about this feature, managed type in Job, at all. More like something we should avoid and should have some edge case support. It should be something that error from the compile time and require marking by specific attribute before error in runtime
     
    vildauget likes this.
  9. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    369
  10. Elivard

    Elivard

    Joined:
    Apr 1, 2020
    Posts:
    10
    Do you plan to include support for Gamma color space? If yes, is it planned for any time soon?
     
  11. IsaacsUnity

    IsaacsUnity

    Unity Technologies

    Joined:
    Mar 1, 2022
    Posts:
    94
    Sylmerria likes this.
  12. F1R1T

    F1R1T

    Joined:
    Mar 28, 2023
    Posts:
    3
    Will addressable work with ecs ?
    If it works, are there any difficulties?
     
  13. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,685
    Occuros likes this.
  14. F1R1T

    F1R1T

    Joined:
    Mar 28, 2023
    Posts:
    3
  15. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,685
    You need to be on Unity discord to see that https://discord.gg/unity
     
    F1R1T likes this.
  16. digimbyte

    digimbyte

    Joined:
    Jun 23, 2012
    Posts:
    58
    graphics module MIA?
    upload_2023-3-30_7-14-37.png
     
  17. linfuqing

    linfuqing

    Joined:
    May 11, 2015
    Posts:
    166
    Hey,it's something wrong in my case:
    Code (CSharp):
    1. public abstract class SystemGroupBase : ComponentSystemGroup
    2. {
    3. }
    4.  
    5. [UpdateInGroup(typeof(SystemGroupBase), OrderFirst = true)]
    6. public partial class MySystem : SystemBase
    7. {
    8. }
    9.  
    10. public partial class MySystemGroup : SystemGroupBase
    11. {
    12. }
    13.  
    Edit:

    This is what's wrong in ComponentSystemGroup.ComputeSystemOrdering:
    Code (CSharp):
    1.         internal static int ComputeSystemOrdering(int sysType, int ourTypeIndex)
    2.         {
    3.             if (ourTypeIndex == -1 || sysType == -1)
    4.                 return 1;
    5.  
    6.             var attrs = TypeManager.GetSystemAttributes(sysType, TypeManager.SystemAttributeKind.UpdateInGroup);
    7.             for (int i=0; i<attrs.Length; i++)
    8.             {
    9.                 var attr = attrs[i];
    10.  
    11.                 //attr.TargetSystemTypeIndex == -1
    12.                 if (attr.TargetSystemTypeIndex == ourTypeIndex)
    13.                 {
    14.                     if ((attr.Flags & TypeManager.SystemAttribute.kOrderFirstFlag) != 0)
    15.                     {
    16.                         return 0;
    17.                     }
    18.  
    19.                     if ((attr.Flags & TypeManager.SystemAttribute.kOrderLastFlag) != 0)
    20.                     {
    21.                         return 2;
    22.                     }
    23.                 }
    24.             }
    25.  
    26.             return 1;
    27.         }
    28.  
     
  18. F1R1T

    F1R1T

    Joined:
    Mar 28, 2023
    Posts:
    3
    How to share data between scene and subscene in unity ecs ?
     
  19. ChristineGallup

    ChristineGallup

    Joined:
    Apr 26, 2023
    Posts:
    1
    From where I can download it?
     
    Last edited: Apr 28, 2023
  20. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,775
    Package manager.
    Instructions are in OP.
     
  21. linfuqing

    linfuqing

    Joined:
    May 11, 2015
    Posts:
    166
    is this bug fixed in next release?
     
  22. IsaacsUnity

    IsaacsUnity

    Unity Technologies

    Joined:
    Mar 1, 2022
    Posts:
    94
    Thanks for flagging this, would you be able to create a bug ticket for this so we can triage it accordingly? Thank you!
     
  23. elliotc-unity

    elliotc-unity

    Unity Technologies

    Joined:
    Nov 5, 2015
    Posts:
    230
    It kind of makes no sense in my opinion to say [UpdateInGroup(typeof(SystemGroupBase))] when SystemGroupBase is abstract. UpdateInGroup is intended to be talking about a specific group which there is exactly one of. If you have two inheritors of the abstract class, do we instantiate your system twice, once per group? Do we just update the same system twice, once per group? Do we just pick a group and ignore the other one? I believe most people would be surprised by every option, pretty much.

    However, we should say this explicitly with an error message, rather than just having weird behavior. We'll fix that.
     
    zandalus, IsaacsUnity and DaxodeUnity like this.
  24. user_29

    user_29

    Joined:
    Jul 5, 2022
    Posts:
    3
    android i2llcp build crashes after unity logo, works in editor without any errors, im new to ECS
    entities 1.0.0-pre.65
    entities.graphics 1.0.0-pre.65
    URP 14.0.7
    any idea whats wrong or what should i be looking into?
     
  25. Jack_Martison

    Jack_Martison

    Joined:
    Jun 24, 2018
    Posts:
    143
    Hey there, I read tons of materials regarding ECS/DOTS stuff, but my main question remains - can it works with placing trees around my landscape?
    Using GPU Instancing still kinda hard with HDRP in terms of performance, I wonder if ECS the best case for placing static object like thousands of trees
     
  26. Dimetrock

    Dimetrock

    Joined:
    Dec 9, 2012
    Posts:
    37
    It works great, I got up to ~250K of trees rendering without issues.
     
    ThynkTekStudio likes this.
  27. BelkinAlex

    BelkinAlex

    Joined:
    Sep 28, 2015
    Posts:
    9
  28. Spy-Master

    Spy-Master

    Joined:
    Aug 4, 2022
    Posts:
    618
  29. linfuqing

    linfuqing

    Joined:
    May 11, 2015
    Posts:
    166
    in a sense I think it‘s very useful.
    such as CustomPhysicsSystemGroupBase in Unity Physics Package:
    Code (CSharp):
    1.  
    2.         protected override void OnUpdate()
    3.         {
    4.             // Can't switch if the sim singleton is null
    5.             if (SystemAPI.GetSingleton<SimulationSingleton>().Type == SimulationType.NoPhysics)
    6.                 return;
    7.  
    8.             // copy systems from PhysicsSystemGroup if first time
    9.             if (!m_DidCloneSystems)
    10.             {
    11.                 AddSystemToUpdateList(World.GetExistingSystemManaged<PhysicsInitializeGroup>());
    12.                 AddSystemToUpdateList(World.GetExistingSystemManaged<PhysicsSimulationGroup>());
    13.                 AddSystemToUpdateList(World.Unmanaged.GetExistingUnmanagedSystem<ExportPhysicsWorld>());
    14.                 AddSystemToUpdateList(World.GetExistingSystemManaged<BeforePhysicsSystemGroup>());
    15.                 AddSystemToUpdateList(World.GetExistingSystemManaged<AfterPhysicsSystemGroup>());
    16.                 AddSystemToUpdateList(World.GetExistingSystemManaged<Unity.Physics.GraphicsIntegration.BufferInterpolatedRigidBodiesMotion>());
    17.                 AddSystemToUpdateList(World.GetExistingSystemManaged<Unity.Physics.GraphicsIntegration.CopyPhysicsVelocityToSmoothing>());
    18.                 AddSystemToUpdateList(World.GetExistingSystemManaged<Unity.Physics.GraphicsIntegration.RecordMostRecentFixedTime>());
    19.                 AddSystemToUpdateList(World.Unmanaged.GetExistingUnmanagedSystem<SyncCustomPhysicsProxySystem>());
    20.  
    21.                 var userSystems = new List<Type>();
    22.                 AddExistingSystemsToUpdate(userSystems);
    23.                 foreach (var sys in userSystems)
    24.                 {
    25.                     AddSystemToUpdateList(World.GetExistingSystemManaged(sys));
    26.                 }
    27.                 userSystems.Clear();
    28.                 AddExistingUnmanagedSystemsToUpdate(userSystems);
    29.                 foreach (var sys in userSystems)
    30.                 {
    31.                     AddSystemToUpdateList(World.Unmanaged.GetExistingUnmanagedSystem(sys));
    32.                 }
    33.  
    34.                 m_DidCloneSystems = true;
    35.                 EnableSystemSorting = true;
    36.             }
    37.  
    38.             ref var bpwData = ref SystemAPI.GetSingletonRW<BuildPhysicsWorldData>().ValueRW;
    39.  
    40.             // change active physics world
    41.             var prevWorld = bpwData.PhysicsData;
    42.             var prevFilter = bpwData.WorldFilter;
    43.             var prevSingleton = SystemAPI.GetSingleton<PhysicsWorldSingleton>();
    44.             bpwData.PhysicsData = m_WorldData;
    45.             bpwData.WorldFilter = m_WorldFilter;
    46.  
    47.             SystemAPI.SetSingleton(new PhysicsWorldSingleton { PhysicsWorld = m_WorldData.PhysicsWorld, PhysicsWorldIndex = m_WorldFilter });
    48.  
    49.             PreGroupUpdateCallback();
    50.  
    51.             base.OnUpdate();
    52.  
    53.             PostGroupUpdateCallback();
    54.  
    55.             // restore active physics world
    56.             m_WorldData = bpwData.PhysicsData;
    57.             m_WorldFilter = bpwData.WorldFilter;
    58.             bpwData.PhysicsData = prevWorld;
    59.             bpwData.WorldFilter = prevFilter;
    60.  
    61.             SystemAPI.SetSingleton(prevSingleton);
    62.         }
    63.     }
    64.  
    Maybe this is not an elegant way to write this system,why can we use UpdateInGroup like this:
    Code (CSharp):
    1.  
    2. UpdateInGroup(typeof(CustomPhysicsSystemGroupBase))
    3. struct PhysicsInitializeGroup : ISystem
    4.  
     
    Last edited: May 18, 2023
  30. IsaacsUnity

    IsaacsUnity

    Unity Technologies

    Joined:
    Mar 1, 2022
    Posts:
    94
    Hello everyone, ECS for Unity is now available with Unity 2022 LTS. Check out our latest roadmap update over here!
     
Thread Status:
Not open for further replies.