UpdateManager
now disables itself while no updatable objects are registered.UpdateManager
is now supported in edit mode. The singleton update manager created in edit mode will be destroyed when entering play mode.- Enabled
AManagedBehaviour
objects with[ExecuteInEditMode]
or[ExecuteAlways]
attributes have theirManagedUpdate
andManagedLateUpdate
methods run in edit mode.
- Support for editing multiple objects in
AJobBehaviourEditor
IBurstUpdateJob<>
andIBurstUpdateTransformJob<>
interfaces to be used in place ofIUpdateJob
andIUpdateTransformJob
when Burst compilation is desired. PassBurstUpdateJob<...>
andBurstUpdateTransformJob<...>
to their type parameters, so that Burst can compile the concrete job types.
AJobBehaviour<,>
,IJobUpdatable<,>
andITransformJobUpdatable<,>
. Use the versions with a single type parameter instead. Now that Burst support was moved toIBurstUpdateJob<>
andIBurstUpdateTransformJob<>
, specified at job struct definition, there is no need to specify the second parameter in job updatable types.
- Removed usage of
ConditionalWeakTable
fromProfilerMarkerMap
implementation, which broke iOS + IL2CPP builds for some reason.
BurstUpdateJob<>
/BurstUpdateTransformJob<>
: Burst-compiled versions ofUpdateJob<>
/UpdateTransformJob<>
- Update job managers now support job data synchronization.
Implement
IJobDataSynchronizer<>
in job providers to synchronize data from registered jobs. Data synchronization occurs right after completing jobs, but before scheduling the new batch, so it is safe to modify their data. One must explicitly register objects for data synchronization by callingSynchronizeJobDataOnce
for a one-time data synchronization next frame, or by passing true toRegisterInManager
to sync data every frame.
UpdateJob<>
/UpdateTransformJob<>
are not marked for compilation with Burst anymore. This avoids warnings about the job being marked for compilation, but no concrete version of the type being defined. UseBurstUpdateJob<>
/BurstUpdateTransformJob<>
instead if you want Burst-compiled update jobs.AUpdateJobManager.IsRegistered
now checks for pending additions/removals. It now returns true if provider is already pending addition and returns false if provider is present in map, but also pending removal.
- Follow Target sample.
AUpdateJobManager.IsRegistered
method to check if an object is registered for updates. Extension methodsIJobUpdatable.IsRegisteredInManager
andITransformJobUpdatable.IsRegisteredInManager
were also added.- Profiler markers for methods managed by
UpdateManager
.
- Only reallocate job data arrays when growing their capacity. This avoids CPU spikes when rapidly removing/adding objects in update job managers.
- Hold Burst shared static in a variable instead of calling
GetOrCreate
everytimeUpdateJobTime
is accessed. - Use a custom
SortedList
implementation instead ofSortedSet
. This avoids heap allocations while iterating over the values.
- Dispose of dependency job handles array before reallocating it.
- Reset job data when removing and re-adding an object in the same frame. This avoids maintaining the wrong state between registrations.
- Support for managed
LateUpdate
andFixedUpdate
methods inUpdateManager
. Similar to managedUpdate
methods, all you need to do is inherit theILateUpdatable
orIFixedUpdatable
interface and register the object in the manager using theRegisterInManager()
extension method.
AUpdateManagerBehaviour
: Prefer inheritingAManagedBehaviour
and implementing theIUpdatable
/ILateUpdatable
/IFixedUpdatable
interfaces directly.
UpdateJobTime.frameCount
type to beint
instead offloat
. This makes it compatible withUnityEngine.Time.frameCount
.
UpdateManager
now uses try/catch blocks for eachManagedUpdate
call. This way, if any managed update call fails, the other ones are not affected.
UpdateJob<>
andUpdateTransformJob<>
are now marked for Burst compilation. Simply use concrete types and Burst will compile the jobs.AJobBehaviour<,>
now inheritsAJobBehaviour<>
and not the other way around. The same is true forIJobUpdatable<,>
andITransformJobUpdatable<,>
.
BurstUpdateJob<>
andBurstUpdateTransformJob<>
types. Simply useUpdateJob<>
andUpdateTransformJob<>
instead.UpdateJobManager<,>
andUpdateTransformJobManager<,>
, which are not necessary anymore.
- Managed jobs with dependencies now work for Burst-compiled jobs.
AJobBehaviour
custom editor that shows current job data in a JSON format while inspecting the object.- Added support for Burst-compiled jobs by specifying
BurstUpdateJob<>
orBurstUpdateTransformJob<>
as the second type parameter to the generic interfacesIJobUpdatable<,>
andITransformJobUpdatable<,>
as well asAJobBehaviour<,>
. - Added support for dependencies between managed jobs by using the
[DependsOn(...)]
attribute. For now, no dependency cycle detection is performed, so job runners may get deadlocked if you misuse it. - Added support for native collections as fields in managed jobs. For now, the thread safety system provided by Unity is not applied to managed jobs native containers, so use them with care!
[JobBatchSize(...)]
attribute for specifying the parallel job batch sizes for each job type.[ReadOnlyTransformAccess]
attribute for markingIUpdateTransformJob
s with read-only transform access.UpdateJobTime
now has static properties with names equal to the ones inUnityEngine.Time
, no need to access usingUpdateJobTime.Instance
anymore.
- Deprecated the
[UpdateJobOptions(...)]
attribute, use[JobBatchSize(...)]
and[ReadOnlyTransformAccess]
instead. They are clearer to read in code.
- Deduplicated code in
UpdateJobManager
andUpdateTransformJobManager
by using the common base classAUpdateJobManager
. UpdateManager.Unregister
complexity is now O(1) instead of O(N). This is due to using an internal Dictionary for caching objects' indices and always removing objects with swap back, the same technique used byAUpdateJobManager
.UpdateJobTime
is now astruct
instead ofclass
and its usage is now supported in Burst-compiled jobs.
- Calling
UpdateManager.Register
with an already registered object is now a no-op instead of registering duplicated entries.
UpdateManager
singleton class that runs managed update methods in registered objects. Supports any C# object that implementsIUpdatable
, including MonoBehaviours, pure C# classes and structs.AUpdateManagerBehaviour
, a MonoBehaviour abstract subclass that automatically registers/unregisters itself inUpdateManager
.UpdateJobManager<>
singleton class that schedules jobs with data provided by registered objects. Supports any C# object that implementsIJobUpdatable<>
.UpdateTransformJobManager<>
singleton class that schedulesTransformAccess
-enabled jobs with data provided by registered objects. Supports any C# object that implementsITransformJobUpdatable<>
.UpdateJobTime
singleton class for accessingUnityEngine.Time
properties from jobs.AJobBehaviour<>
, a MonoBehaviour abstract subclass that automatically registers/unregisters itself inUpdateTransformJobManager<>
.[UpdateJobOptions(...)]
attribute that specifies parallel job batch sizes and whether transforms are read-only.