Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Official Entities 1.1 experimental release now available

Discussion in 'Entity Component System' started by jivalenzuela, Sep 21, 2023.

  1. jivalenzuela

    jivalenzuela

    Unity Technologies

    Joined:
    Dec 4, 2019
    Posts:
    67
    Howdy;

    The DOTS team has just released the 1.1.0-exp.1 of the Entities packages. These changes include bug fixes, optimizations, and new APIs to the Entities 1.0 release. In addition some APIs have been deprecated.

    For those requiring the highest level of safety, we recommend sticking to patch releases of the Entities 1.0. For most users, however, this should be a drop-in replacement.

    Versions of the following packages have been made available:

    com.havok.physics@1.1.0-exp.1
    com.unity.collections@2.3.0-exp.1
    com.unity.entities.graphics@1.1.0-exp.1
    com.unity.entities@1.1.0-exp.1
    com.unity.logging@1.1.0-exp.1
    com.unity.netcode@1.1.0-exp.1
    com.unity.physics@1.1.0-exp.1


    Follow the instructions for using non-release packages from Package Manager to install.

    An incomplete list of additions and changes follows.

    com.unity.entities@1.1.0-exp.1

    Added

    • Added a "Custom Transform System" folder in the assets folder of the "EntitiesSamples" project.
    • Enabled model assets to be baked as prefabs using EntityPrefabReference.
    • Error DC0084 is generated when capturing a local variable in an Entities.ForEach that isn't used.
    • Add GetSharedComponentIndexManaged API
    • Added additional errors around improper use of SystemAPI methods with generic type arguments.
    • Search Keyword registration for entities preferences and settings.
    • SystemAPI.Query<T> now supports WithSharedComponentFilterManaged<T>(T sharedComponent) and WithSharedComponentFilterManaged<T1, T2>(T1 sharedComponent1, T2 sharedComponent2).
    • CompleteDependencyBeforeRW(SystemState state) and CompleteDependencyBeforeRO(SystemState state) are added to the public Unity.Entities.IAspectCreate<T> interface in order to faciltiate changes to source-generated code. Implementations of these methods, like all existing methods in Unity.Entities.IAspectCreate<T>, will automatically be generated on users' behalf by source generators.
    • Added IBaker.CreateAdditionalEntities for creating multiple additional entities at once.
    • filter to search with SharedComponent from within the Hierarchy Window and Search Window
    • New EntityQuery component type constraint: Present components are required to be present on a query's matching archetypes, whether or not they are enabled or disabled on individual entities. This constraint can be added in all the usual places -- EntityQueryBuilder.WithPresent<T>(), EntityQueryDesc.Present[], the [WithPresent(typeof(T))] attribute on IJobEntity, etc.
    • checks to see if an exclusive transaction is active while scheduling a job.
    • Specific error when capturing a variable in Entities.ForEach that relies on relies on source generators (since there is no deterministic order between source generators, this can be an error).

    Changed

    • Significantly improved the performance of EntityManager.SetSharedComponent<T>(EntityQuery,T) and EntityManager.SetSharedComponentManaged<T>(EntityQuery,T)
    • TypeManager.Initialize will disable synchronous Burst compilation only during initialization of the TypeManager so that large synchronous compilation stalls when compiling function pointers can be avoided when iterating in the Editor.
    • BlobBuilder is now partial
    • CompanionGameObjectUpdateTransformSystem, ResetUpdateAllocator, and SubSceneInspectorUtility are now public
    • Batch primary entity creation in baking.
    • HasSingleton<T>() and TryGetSingleton<T>() methods will now throw if they find >1 instance of T, instead of returning false. Having more than one instance of a singleton component indicates a bug in the program, and should fail more obviously.
    • The visibility of the EnabledBitUtility class was changed from public to internal. This class was never intended to be part of the public API of the Entities package, and should not be used by application code.
    • EntityManager.AddChunkComponentData(EntityQuery,T) no longer throws an exception if the component T is already present on any of the target chunks. Instead, the new value is assigned to the existing component. This matches the behavior of other AddComponent variants in the Entities package.
    • Text for exception that occurs when an entity doesn't exist during EntityCommandBuffer playback.
    • IJobChunk now allows indexed writes to native containers passed in the job struct. Only writes to the element at unfilteredChunkIndex are valid. To disable this check on a per-container basis, add [NativeDisableParallelForRestriction] to the relevant field in the job struct.

    Deprecated and removed

    • Deprecate GetSharedComponentDataIndex as it is a duplicate of GetSharedComponentIndex
    • Removed gizmo rendering logic for entities from C#, now this is handled natively in Unity.
    • Marked EntityManager.Instantiate(NativeArray<Entity> srcEntities, NativeArray<Entity> outputEntities) as obsolete, with the intention to eventually remove it entirely.

    com.unity.netcode@1.1.0-exp.1

    Added

    • source generator can now be configure to enable/disable logs, report timings. It also possible to set the minimal log level (by default is now Error).
    • new public template specs and generator documentation
    • Added convenience methods for getting the clientworld / serverworld (or thin client list) added to ClientServerBootstrap
    • Additional analytics events. Multiplayer tools fields, prediction switching counters, tick rate configuration.
    • New method on the PredictedFixedStepSimulationSystemGroup class to initialise the rate as a multiple of a base tick rate.
    • Packet Fuzz % is now configurable via the Network Simulator. It's a security tool that should not be enabled during normal testing. It's purpose is to test against malicious MitM attacks, which aim to take down your server via triggering exceptions during packet deserialization. Thus, all deserialization code should be written with safeguards and tolerances, ensuring your logic will fail gracefully.
    • CopyInputToCommandBufferSystemGroup group, that contains all the system that copy IInputCommandData to the underlying ICommand buffer. This let you now target this group with the guarantee that all inputs are not copied after it run.
    • CopyCommandBufferToInputSystemGroup group, that contains all the system that copy ICommandData to their IInputCommandData representation. It runs first in the prediction loop and you can easily target it to do logic before or after the input are updated.
    • GhostSpawnClassificationSystemGroup, that is aimed to contains all your classification systems in one place.
    • Error messages to some missing NetworkDriver.Begin/EndSend locations.
    • defining ENABLE_UNITY_RPC_REGISTRATION_LOGGING will now log information about registered RPCs during netcode startup
    • We now automatically detect Application.runInBackground being set to false during multiplayer gameplay (a common error), and give advice via a suppressible error log as to why it should be enabled.
    • We introduced the new InputBufferData<T> buffer, that is used as underlying container for all IInputComponentData.
    • conditional compilation for some public interfaces in DefaultDriverBuilder to exclude the use of RegisterServer methods for WebGL build (they can't listen). It is possible to do everything manually, but the helper methods are not present anymore.
    • new method for creating a NetworkDriver using WebSocketNetworkInterface.
    • Added two new values to the NetworkStreamDisconnectReason enum: AuthenticationFailure and ProtocolError. The former is returned when the transport is configured to use DTLS or TLS and it fails to establish a secure session. The latter is returned for low-level unexpected transport errors (e.g. malformed packets in a TCP stream).

    Changed

    • relaxed public field condition for variants. When declaring a ghost component variations, the variant fields are not required to be public. This make the type pretty much unusable for any other purpose but declaring the type serialisation.
    • Increased the ThinClient cap on MultiplayerPlayModePreferences.MaxNumThinClients from 32 to 1k, to facilitate some amount of in-editor testing of high-player-counts.
    • NetcodeTestWorld updates the worlds in the same way the package does: first server, then all clients worlds.
    • When Dedicated Server package is installed, the PlayMode Type value is overridden by the active Multiplayer Role.

    Deprecated

    • The public PredictedFixedStepSimulationGroup.TimeStep. You should always use the PredictedFixedStepSimulationGroup.ConfigureTimeStep to setup the rate of the PredictedFixedStepSimulationSystemGroup..
    • the IInputBufferData interface (internal for code-gen use but public) has been deprecated and will be removed in the 1.2 release.

    Fixed

    • incorrect code generated serialization and calculated ChangeMask bits for component and buffers when the GhostFieldAttribute.Composite flag is set to true (in some cases).
    • wrong check for typename in GhostComponentVariation
    • missing region in unquantized float template, causing errors when used for interpolated field.
    • improper check when the ClientServerSetting asset is saved, causing worker process not seeing the changes in the settings.
    • The server world was not setting the correct rate to the group, if that was not done as part of the bootstrap.
    • Exception thrown when the NetDbg tools is connecting to either the editor or player.
    • Renamed (and marginally improved) the "Multiplayer PlayMode Tools" Window to the "PlayMode Tools" Window, to disambiguate it from "[MPPM] Multiplayer Play Mode" (an Engine feature).
    • Attempting to access internals of Netcode for Entities (e.g. via Assembly Definition References) would cause compiler errors due to MonoPInvokeCallbackAttribute being ambiguous between AOT and Unity.Entities.
    • Packet dump logging exception when using relevancy, despawns, and packet dumps enabled. Also fixed performance overhead (as it was erroneously logging stack traces).
    • An issue with variant hash calculation in release build, causing ghost prefab hash being different in between development/editor and release build.
    • GhostUpdateSystem.RestoreFromBackup does not always invalidate/bump the chunk version for a component, but only if the chunk as changed since the last time the restore occurred.
    • Issue in TryGetHashElseZero, that was using the ComponentType.GetDebugName to calculate the variant hash, leading incorrect results in a release player build
    • A NetworkDriver.BeginSend error causing an infinite loop in the RpcSystem.
    • Deprecated Analytics API when using 2023.2 or newer.
    • compilation issue when using 2023.2, caused by an ambiguous symbol (define in both Editor and in Entities.Editor assembly)
    • Errant netcode systems no longer show up in the DefaultWorld: PhysicsWorldHistory, SwitchPredictionSmoothingPhysicsOrderingSystem, SwitchPredictionSmoothingSystem, GhostPresentationGameObjectTransformSystem, GhostPresentationGameObjectSystem, and SetLocalPlayerGraphicsColorsSystem.
    • Previous was hard to retrieve the generated buffer for a given IInputComponentData. Now is easy as doing something like InputBufferData<MyInputComponent>.
    • Compilation error when building for WebGL
    • SnapshotDataLookupCache not created in the correct order, causing custom classification system using the SnapshotBufferHelper to throw exceptions, because the cache was not initialised.
    • A replicated [GhostEnabledBit] flag component would throw an ArgumentException when added to a Prespawned Ghost due to ArchetypeChunk.GetDynamicComponentDataArrayReinterpret.

    com.unity.physics@1.1.0-exp.1

    Added

    • Tests for ensuring proper joint anchor and mass property baking
    • new demo scene (5m. Collider Modifications) demonstrating how to create colliders during runtime
    • Utility functions were added for the creation of MeshCollider blob assets from UnityEngine.Mesh, UnityEngine.MeshData and UnityEngine.MeshDataArray. These functions are located in the MeshCollider class as `MeshCollider.Create' variants with different function signatures.
    • Users can now verify if a collider blob is unique, and make it unique easily if required. The newly introduced PhysicsCollider.IsUnique property lets users check if a PhysicsCollider is unique and turn it into a unique collider if desired via the function PhysicsCollider.MakeUnique(). Making a collider unique with this function also takes care of the collider blob lifetime management and will automatically dispose it if it is no longer needed.
    • Added a custom entity inspector for the collider blob asset stored in the PhysicsCollider component. This inspector allows for two-way interaction with the collider. The displayed values update in accordance with the collider's latest runtime state, and the UI can be used in order to interact with the collider manually when it is unique (see PhysicsCollider.IsUnique). Among others, this lets users try out different material properties at runtime, such as friction and restitution, or modify the collider's size, local position or orientation.

    Changed

    • Changed the bool flags in the Physics Debug Display authoring component for drawing colliders, collider edges and axis-aligned bounding boxes of colliders to an enum called DisplayMode. With the display mode you can now choose whether to draw these elements at the beginning of the simulation step or at the end of the simulation step after the rigid bodies have been integrated, meaning, they have been moved forward in time.
    • Convert SystemBase to ISystems.
    • Joint baking for built-in 3D physics joints has been improved, leading to the expected simulation results. Now, when the Spring and Damping properties in Configurable and Character Joints are both set to 0 for limits, a hard limit is modeled. This is equivalent to the behavior in built-in 3D physics. Also, the Damping parameter is now correctly converted from damping coefficient to the Unity Physics damping ratio for joints, yielding the correct damping force. Furthermore, joint baking now considers the scale of game objects. Anchor points are now affected by the scale accordingly.
    • The formula which converts the user-specified joint relaxation parameters (spring frequency and damping ratio) to the internal constraint regularization parameters (tau and damping) was rewritten as an optimized closed-form expression with constant time complexity. The regularization parameters can now be efficiently computed regardless of the chosen solver iteration count.
    • PhysicsGraphicalSmoothing has been added to .WithAll<>() from .WithAllRW<>() in the SmoothedDynamicBodiesQuery variable within SmoothRigidBodiesGraphicalMotion.cs system file.
    • Updating APIs to GetScriptingDefineSymbols() and SetScriptingDefineSymbols().
    • Included ragdoll authoring in documentation
    • Prefab instances will now contain unique colliders if the "force unique" collider authoring option is used. This allows collider runtime modifications without manual collider blob cloning now also on prefab instances. Note that prefab instances that contain "force unique" colliders will be made unique only after the next physics system group update following the prefab instantiation. Until then, the PhysicsCollider.IsUnique property will be false. If users require a unique collider immediately after prefab instantiation for runtime collider modifications, they can safely use the new PhysicsCollider.MakeUnique() function immediately after instantiation.
    • Updated Burst dependency to version 1.8.8
    • The internal component DrawComponent, required by the Physics Debug Display, is now hidden in the hierarchy.

    Deprecated and removed

    • The Constraint.DefaultSpringDamping variable was deprecated. Use Constraint.DefaultDampingRatio instead. The same applies to the Constraint.SpringDamping property which was deprecated. Instead the new Constraint.DampingRatio property should be used.
    • Remove unused internal debug draw functionalities which were causing slowdowns during world initialization

    Fixed

    • BuildCompoundCollidersBakingSystem no longer leaks memory when the world is disposed.
    • Convert SystemBase to ISystems
    • When using the built-in Rigidbody and Collider authoring components, the inertia tensor of the resultant rigid body in Unity Physics is now set correctly in all situations. Previously, in certain cases, the default inertia tensor was used.
    • A problem which prevented the solver to respect the user-specified joint spring frequency and damping ratios in certain cases has been fixed, enabling physically-plausible modeling of joints under all operating conditions.
    • Link to changelog in documentation now fixed
    • Physics Shape components with type Mesh now correctly only use the Custom Mesh for MeshCollider creation if specified rather than also incorrectly including the game object's render mesh and any render mesh found in the game object's children. The previous erroneous behavior could lead to significant performance problems in the narrow phase (contact creation) of the physics simulation group for affected meshes.
    • Updated documentation to reflect that the Built-In TerrainCollider is not yet supported by Unity Physics

    com.unity.logging@1.1.0-exp.1

    Added

    • When using RedirectUnityLogs, native logs (logs emitted from C++ code in Unity) will now also be redirected. Note that this is only available in player builds as a current limitation prevents this redirection from working in the editor. Redirection of logs emitted by C# code remains supported both in player builds and in the editor, however.

    Fixed

    • Under stress, it was possible to drop a log message.
    • Allow empty strings in logging messages
    • Performance issue with LogControllerWrapper.GetLogControllerIndexUnderLockNoThrow when creating many worlds.
    • Log sinks forwarded to UnityDebugLogSink will now no longer extract erroneous stacktraces from UnityDebugLogSink.cs. While it does not correctly forward stacktraces (if enabled), it at least doesn't report incorrect ones.
    • Fixed an issue where OutputTemplate is ignored when logging into UnityEditorConsole.

    com.unity.collections@2.3.0-exp.1

    Added

    • Added a new GetUnsafeReadOnlyPtr method to DataStreamReader. This can be used as an escape hatch if access to the underlying buffer of the stream reader is required.

    Fixed

    • A previous release did not allow unsafeList.RemoveRange(unsafeList.Length, 0) anymore, which could cause failures in many common algorithms. This has been fixed.
    • Made SortJob.SegmentSort, and SortJob.SegmentSortMerge public to allow generic job type registration.
    • UnsafeList.RemoveAtSwapBack could read invalid memory when the last element of the list is removed
    • Data elements in FixedList<T, U> now respect natural alignment for the type T

    com.unity.entities.graphics@1.1.0-exp.1

    Added

    • Support for using a mesh in multiple LODs within a LODGroup when in a subscene.
    • A variation of RenderMeshUtility.AddComponents that does not need a RenderMeshArray
    • Support maximum LOD level quality setting within a subscene.
    • Add support for multiple submeshes per entity. Stop creating one entity per submesh unless skinning is used.
    • Support for decal projector components in a subscene.
    • Cull based on CullLightmapShadowCasters flag in FrustumCullingJob

    Changed

    • MaterialMeshInfo now inherits IEnableable and allows high frequency state changes

    Fixed

    • Address incorrect motion vector calculation on initial frame.
    • JobTempAlloc warnings that might occur under some circumstances.
    • Rendering without a RenderMeshArray component
    • Addresses rendering artifacts when Entities Graphics GPU allocation fails
    • Memory leaks in Burst Occlusion Culling
    • Support for DecalProjector in URP added to CompanionComponentSupportedTypes
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,626
  3. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    908
    Reaaaaal nice! (sorry I don't have more to add, might edit :D )
     
  4. Yoraiz0r

    Yoraiz0r

    Joined:
    Apr 26, 2015
    Posts:
    60
    Awesome update!

    Would this address the issue mentioned in This post? Specifically in that if you create an input data type and want thin clients, can you now add the specific input's buffer without code generation not being fully detected in IDEs?
     
  5. mrbinggrae

    mrbinggrae

    Joined:
    Mar 6, 2016
    Posts:
    14
    bb8_1 likes this.
  6. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,653
    UniqueCode and JesOb like this.
  7. svgampel-carx-tech

    svgampel-carx-tech

    Joined:
    Oct 28, 2016
    Posts:
    1
    That's pretty cool, but Havok on iOS still provided as .dylib - it's not allowed on iOS. You was already fixing it before DOTS 1.0, but since DOTS 1.0 it's broken again.
     
    Last edited: Sep 21, 2023
  8. jivalenzuela

    jivalenzuela

    Unity Technologies

    Joined:
    Dec 4, 2019
    Posts:
    67
    Thanks, we're aware of the issue and currently working on a fix.
     
    svgampel-carx-tech likes this.
  9. Touhma_Slater

    Touhma_Slater

    Joined:
    Nov 19, 2014
    Posts:
    20
    Trying to update the packages and :

    When only updating physics :

    error CS0006: Metadata file 'Library/PackageCache/com.unity.ext.nunit@2.0.3/net35/unity-custom/nunit.framework.dll' could not be found

    ( even after library cleanup )

    And after updating everything :

    Failed to find entry-points:
    Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Assembly-CSharp-Editor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' ---> System.Exception: Failed to resolve assembly 'Assembly-CSharp-Editor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' in directories: C:\Program Files\Unity\Hub\Editor\2022.3.10f1\Editor\Data\MonoBleedingEdge\lib\mono\unityjit-win32




    error SGICE002: This error indicates a bug in the DOTS source generators



    Any solutions for that ?
     
  10. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    If it helps, I had the above errors, as well as subscenes simply not loading. Closing Unity, clearing the library folder, and reopening the project fixed everything and cleared the errors.
     
    tangell likes this.
  11. Touhma_Slater

    Touhma_Slater

    Joined:
    Nov 19, 2014
    Posts:
    20
    Unfortunately all of that I tried multiple times , it do not solve anything for me :/ but thanks mate
     
  12. mrbinggrae

    mrbinggrae

    Joined:
    Mar 6, 2016
    Posts:
    14
    Is there any DOTS 1.0.16 tutorial?
     
  13. linfuqing

    linfuqing

    Joined:
    May 11, 2015
    Posts:
    166
    Any ETA for BurstCompile a ComponentSystemGroup?
     
  14. WAYNGames

    WAYNGames

    Joined:
    Mar 16, 2019
    Posts:
    939
    Is it compatible with unity 2023 version or do we still have to stick to 2022 ?
     
    herkip, Opeth001 and bb8_1 like this.
  15. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,574
    It works with 2023 o my side.
     
  16. tangell

    tangell

    Joined:
    Aug 11, 2017
    Posts:
    18
    Thanks for this. I was also experiencing issues loading subscenes and clearing the Library folder cleared up my issue.
     
    Karearea likes this.
  17. te_headfirst

    te_headfirst

    Joined:
    Aug 1, 2023
    Posts:
    8
    Super with the update.. Still cannot find a way in ECS to set BelongsTo and CollidesWith collision filters on entities using RidigBody and Collider. (As PhysicsBody and PhysicsShape is only used in Samples code I would not like to include in production code base).
    1. Are there any news on what will happen to (deprecated) PhysicsBody and PhysicsShape?
    2. How do I set BelongsTo and CollidesWith collision filters when using a RigidBody and a Collider (and not PhysicsBody and PhysicsShape)?
     
  18. tangell

    tangell

    Joined:
    Aug 11, 2017
    Posts:
    18
    You should be able to use normal colliders and their layers (not PhysicsShape and PhysicsBody). Alternatively, in code try something like this:


    var belongsToMask = 1u << layerNumber;
    var collidesWithMask = 1u << layerNumber;
    var filter = new CollisionFilter { BelongsTo = belongsToMask, CollidesWith = collidesWithMask };
    physicsCollider.Value.Value.SetCollisionFilter(filter); // where physicsCollider is your Unity.Physics.Collider
     
    daniel-holz and te_headfirst like this.
  19. te_headfirst

    te_headfirst

    Joined:
    Aug 1, 2023
    Posts:
    8
    Thank you so much :) I guess I had starred my self blind going in all sorts of wrong directions.

    I ended up based on the suggestions in your post to create a CollisionFilterAuthoring component with two custom (flagged enum) properties and called them BelongsTo and CollidesWith which when put on a Prefab will set a TemporaryBakingType on the entity and then a CustomCollisionFilterSystem that picks this up and sets the collision filters on the PhysicsCollider (I set everything is set up to run only when baking systems run)

    Of course this bypasses the built-in layers functionality but if you wish to use that, the same setup can easily be adapted to tap into Include Layers, Exclude Layers and GetLayer() of the Prefab and set Collision Filters accordingly.
     
    tangell and daniel-holz like this.