Skip to content

Commit

Permalink
Add version 1.0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
matteblair committed Aug 23, 2023
1 parent 50b11fa commit 2d5a2ab
Show file tree
Hide file tree
Showing 105 changed files with 2,642 additions and 876 deletions.
4 changes: 2 additions & 2 deletions .signature
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"timestamp": 1684982863,
"signature": "C1AJ/KZmfCU2V+KlhIKuCqVncKltmWYgTeBw+dJu2ZteXgegQyRkgRPLL+AhTtzT1imsYbVpJZESLInrIGWHfK7X3MJNvRa9hI5Wd1684zbfYh3BxHzWo4EzG4IgBnzW4DHbRN+3V90ro6OTAyWZQ6ULEEiZSz/Lycf4573gWuJX2ZCs+wp+Uywy/eiBl1lTU0hEaf3wyw7HC+BqwsbTGP5CyaaeKO9RoMS9T3yNKFI70wJ2+ZifKeUDXDl695Rw0hS07U4Omjt8kXfbadHha6uIHdBD8/VyLd/cUiLewWZPPW4Z2RYJZztzG1xYEVF+fMtsTgGbcUoLsze8r24RFhIhP1q1LL1s362txkQZM8vZYp+fWaOZJbujH+NXk0SPj5qxXmJSq5EcJc2JfJRvagXDd12dFb0o7yTwfe809KBu/1Udv6bJPS25e2VpUH54ZgGCOO9BnZ0JX9Ru1UbP0yor/ER3ykqlSizdfC7SIWZMxXP7y7tPQ2AOT4wVCNIL",
"timestamp": 1687275887,
"signature": "M7JKoAa0tgjALvTUSdFJBqYXLQ3eVvUXexPpv8F8UqgLeAaGSB3I3An1SYHYrd8+pZ7uN38wYTDr3ddf2qoBSlh/pZ7/0+qgAgEjz1CE429thGum4XWFKvGcN/JIDIrAbuKAMJEMmMLG+0pEGoknWx8L12po69j+twPCPVmF9KNayrJaVjUodSmzu2v5EOa+8bwVHkpebTAaM8cPa4CWagQEcMjWUPYK1fRuy6Gssr+wcQwqkdy+8KyIXRWPRTi3M8s/x3ojiLuxhQshhNzqc1/O7b8pIuu2mIg16W4jMy/p/T4ZghjBxL+5BJTP/Hs9zNibTMw+clUW6HBqG5lnyKAdDSQw26r/NV13mlcZHoMvHCoD5pnptGbGU43W8ookroFNn3zpdhe8/kws4Bb9DFg1resI5CrTdZRVUUgh41JONP4+YjA+4uVyXbsAoLTYtxeZLkYSHVlLPeAT6yj0Bs+vQyAOk9douWzmFeskutHSHfeTk8Z4efGRk8KWKrgc",
"publicKey": "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQm9qQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FZOEFNSUlCaWdLQ0FZRUFzdUhXYUhsZ0I1cVF4ZEJjTlJKSAordHR4SmoxcVY1NTdvMlZaRE1XaXhYRVBkRTBEMVFkT1JIRXNSS1RscmplUXlERU83ZlNQS0ZwZ1A3MU5TTnJCCkFHM2NFSU45aHNQVDhOVmllZmdWem5QTkVMenFkVmdEbFhpb2VpUnV6OERKWFgvblpmU1JWKytwbk9ySTRibG4KS0twelJlNW14OTc1SjhxZ1FvRktKT0NNRlpHdkJMR2MxSzZZaEIzOHJFODZCZzgzbUovWjBEYkVmQjBxZm13cgo2ZDVFUXFsd0E5Y3JZT1YyV1VpWXprSnBLNmJZNzRZNmM1TmpBcEFKeGNiaTFOaDlRVEhUcU44N0ZtMDF0R1ZwCjVNd1pXSWZuYVRUemEvTGZLelR5U0pka0tldEZMVGdkYXpMYlpzUEE2aHBSK0FJRTJhc0tLTi84UUk1N3UzU2cKL2xyMnZKS1IvU2l5eEN1Q20vQWJkYnJMbXk0WjlSdm1jMGdpclA4T0lLQWxBRWZ2TzV5Z2hSKy8vd1RpTFlzUQp1SllDM0V2UE16ZGdKUzdGR2FscnFLZzlPTCsxVzROY05yNWdveVdSUUJ0cktKaWlTZEJVWmVxb0RvSUY5NHpCCndGbzJJT1JFdXFqcU51M3diMWZIM3p1dGdtalFra3IxVjJhd3hmcExLWlROQWdNQkFBRT0KLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg"
}
41 changes: 41 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
# Changelog


## [1.0.11] - 2023-6-19

### Added

* The new `EntityQueryOptions.IncludeMetaChunks` flag allows queries to match archetypes with the `ChunkHeader` component (which is excluded from queries by default).

### Changed

* Idiomatic `foreach` and `Entities.ForEach` will now only sync jobs read/writing to component data the foreach will iterate over when the underlying EntityQuery used by the foreach indeed has entities to iterate over. Previously jobs would be unilaterally sync'd when using these constructs which could create stalls on the main thread on jobs that did not need to occur.
* Significantly improved the performance of `EntityCommandBuffer.AsParallelWriter()` and `EntityCommandBuffer.Dispose()`.
* Change component attribute name from `Alignment in Chunk` to `Component Type Alignment in Chunk` when displaying component attributes in Inspector window.
* LinkedEntityGroup internal buffer capacity set to 1.

### Deprecated

* `EntityCommandBuffer` methods which target an `EntityQuery` now take a new `EntityQueryCaptureMode` parameter, used to specify whether the provided query should be evaluated at record time (immediately) or at playback time (deferred). `.AtRecord` matches the existing behavior for compatibility, but `.AtPlayback` is up to 200x faster for some commands. The variants which do not include this extra parameter have been deprecated, but their existing behavior and semantics are preserved. The safe and easy fix is to add `EntityQueryCaptureMode.AtRecord` to all call sites; however, users are encouraged to review all call sites to see if the faster `.AtPlayback` mode would be appropriate.

### Removed

* Alignment attribute is removed when displaying component attributes in Inspector window.

### Fixed

* Updated code samples in documentation for building content archives and content delivery.
* Systems window's tree view indents are now enforced to the proper width.
* Systems window's world and namespace columns are now left aligned.
* You now can register generic ISystems so that they can be discovered and created automatically with world creation, or created manually via CreateSystem. Register each generic instance of them with `[assembly: RegisterGenericSystemType(typeof(YourGenericSystem<YourParticularType>))]` to allow such usage.
* Entities Hierarchy: Fix an exception happening when dragging a gameobject over a subscene node.
* Entities Hierarchy: Disable Empty Scene menu item when creating new subscenes where the main scene is not saved.
* Entities Hierarchy: fix a missing dispose in change collectors.
* Current selection is cleared if an object is selected outside Systems window.
* Current selection is cleared if an object is selected outside Components window.
* Current selection is cleared from Components window when entering/exiting play mode.
* Native memory leak when creating EntityQuery with EntityManager.CreateEntityQuery
* Ensures both readers and writer dependencies are completed when accessing read/write components in certain code paths
* Fixed a crash happening in `EntityCommandBuffer.Dispose` due to a use-after-free bug
* `TypeManager` methods such as `GetSystemName` previously could crash after adding new system type information at runtime due to the `TypeManager` referring to invalid memory.
* Bursted generic ISystems defined in one assembly and registered in another no longer break compilation.


## [1.0.10] - 2023-05-23

### Added
Expand Down Expand Up @@ -45,6 +85,7 @@
* `EntityManager.DestroyEntity(EntityQuery)` had an undocumented constraint: if any of the target entities have a `LinkedEntityGroup` buffer component, the entities in that buffer must also match the target query. This constraint is now documented, and consistently applied in all code paths of this function.
* You now can register generic ISystems so that they can be discovered and created automatically with world creation, or created manually via CreateSystem. Register each generic instance of them with `[assembly: RegisterGenericSystemType(typeof(YourGenericSystem<YourParticularType>))]` to allow such usage.


### Known Issues

* Some errors are surfaced when importing the Entities package into a 2D project. To bypass this issue, restart the editor once the package has been imported.
Expand Down
79 changes: 79 additions & 0 deletions DocCodeSamples.Tests/EnableableComponentExample.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using Unity.Entities;
using Unity.Collections;

namespace Doc.CodeSamples.Tests
{
public struct Health : IComponentData, IEnableableComponent
{
public float Value;
}

public struct Translation : IComponentData, IEnableableComponent
{

}

#region enableable-example
public partial struct EnableableComponentSystem : ISystem
{

public void OnUpdate(ref SystemState system)
{

Entity e = system.EntityManager.CreateEntity(typeof(Health));

ComponentLookup<Health> healthLookup = system.GetComponentLookup<Health>();

// true
bool b = healthLookup.IsComponentEnabled(e);

// disable the Health component of the entity
healthLookup.SetComponentEnabled(e, false);

// though disabled, the component can still be read and modified
Health h = healthLookup[e];

}

}
#endregion

#region enableable-health-example
public partial struct EnableableHealthSystem : ISystem
{

public void OnUpdate(ref SystemState system)
{

Entity e1 = system.EntityManager.CreateEntity(typeof(Health), typeof(Translation));
Entity e2 = system.EntityManager.CreateEntity(typeof(Health), typeof(Translation));

// true (components begin life enabled)
bool b = system.EntityManager.IsComponentEnabled<Health>(e1);

// disable the Health component on the first entity
system.EntityManager.SetComponentEnabled<Health>(e1, false);

EntityQuery query = new EntityQueryBuilder(Allocator.Temp).WithAll<Health, Translation>().Build(ref system);

// the returned array does not include the first entity
var entities = query.ToEntityArray(Allocator.Temp);

// the returned array does not include the Health of the first entity
var healths = query.ToComponentDataArray<Health>(Allocator.Temp);

// the returned array does not include the Translation of the first entity
var translations = query.ToComponentDataArray<Translation>(Allocator.Temp);

// This query matches components whether they're enabled or disabled
var queryIgnoreEnableable = new EntityQueryBuilder(Allocator.Temp).WithAll<Health, Translation>().WithOptions(EntityQueryOptions.IgnoreComponentEnabledState).Build(ref system);

// the returned array includes the Translations of both entities
var translationsAll = queryIgnoreEnableable.ToComponentDataArray<Translation>(Allocator.Temp);

}


}
#endregion
}
11 changes: 11 additions & 0 deletions DocCodeSamples.Tests/EnableableComponentExample.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions DocCodeSamples.Tests/content-management/DeliverContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ public class GameStarter : MonoBehaviour
void Start()
{
#if ENABLE_CONTENT_DELIVERY
ContentDeliverySystem.Instance.UpdateContent(remoteUrlRoot, initialContentSet);
ContentDeliverySystem.Instance.RegisterForContentUpdateCompletion(s =>
{
LoadMainScene();
});
ContentDeliveryGlobalState.Initialize(remoteUrlRoot, Application.persistentDataPath + "/content-cache", initialContentSet, s =>
{
if (s >= ContentDeliveryGlobalState.ContentUpdateState.ContentReady)
LoadMainScene();
});
#else
LoadMainScene();
#endif
Expand Down
2 changes: 1 addition & 1 deletion Documentation~/allocators-custom-prebuilt-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You can use prebuilt custom allocators to manage allocations in [worlds](concept

These prebuilt allocators are custom allocators. To allocate and deallocate `Native-` collection types and `Unsafe-` collection types see the Collections package documentation on [How to use a custom allocator](https://docs.unity3d.com/Packages/com.unity.collections@latest/index.html?subfolder=/manual/allocator-custom-use.html).

## Further information
## Additional resources

* [Allocators overview](allocators-overview.md)
* [Rewindable allocators](https://docs.unity3d.com/Packages/com.unity.collections@latest/index.html?subfolder=/manual/allocator-rewindable.html)
Expand Down
2 changes: 1 addition & 1 deletion Documentation~/allocators-entity-command-buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ During the registration, the entity command buffer allocator of the parent entit

The entity command buffer allocator works in the background, and you don't need to make specific code changes to use it.

## Further information
## Additional resources

* [Allocators overview](allocators-overview.md)
* [Rewindable allocators](https://docs.unity3d.com/Packages/com.unity.collections@latest/index.html?subfolder=/manual/allocator-rewindable.html)
Expand Down
2 changes: 1 addition & 1 deletion Documentation~/allocators-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The different allocators have the following different features:
|[Entity command buffer allocator](allocators-entity-command-buffer.md)|Yes - a rewindable allocator|No|Same as the entity command buffer|Yes|Yes|
|[System group allocator](allocators-system-group.md)|Yes - a double rewindable allocator|Yes|2 fixed rate system group updates|Yes|Yes|

## Further information
## Additional resources

* [Custom prebuilt allocators overview](allocators-custom-prebuilt-intro.md)
* [Rewindable allocators](https://docs.unity3d.com/Packages/com.unity.collections@latest/index.html?subfolder=/manual/allocator-rewindable.html)
Expand Down
2 changes: 1 addition & 1 deletion Documentation~/allocators-system-group.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ In the example below, the system group allocator is used in `ExampleSystemGroupA

[!code-cs[world-update-allocator-worl](../Unity.Entities.Tests/AllocatorsCustomPrebuiltTests.cs#world-update-allocator-system-state)]

## Further information
## Additional resources

* [Allocators overview](allocators-overview.md)
* [Rewindable allocators](https://docs.unity3d.com/Packages/com.unity.collections@latest/index.html?subfolder=/manual/allocator-rewindable.html)
Expand Down
2 changes: 1 addition & 1 deletion Documentation~/allocators-world-update.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The following is an example of accessing the world update allocator through Syst

[!code-cs[Access world update allocator through SystemState.WorldUpdateAllocator](../Unity.Entities.Tests/AllocatorsCustomPrebuiltTests.cs#world-update-allocator-system-state)]

## Further information
## Additional resources

* [Allocators overview](allocators-overview.md)
* [Rewindable allocators](https://docs.unity3d.com/Packages/com.unity.collections@latest/index.html?subfolder=/manual/allocator-rewindable.html)
Expand Down
2 changes: 1 addition & 1 deletion Documentation~/aspects-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Aspects can include items such as the following:
* Any `ISharedComponent` fields to access the shared component value as read-only.
* Other aspect types

## Further information
## Additional resources

* [Create an aspect](aspects-create.md)
* [`IAspect` API documentation](xref:Unity.Entities.IAspect)
2 changes: 1 addition & 1 deletion Documentation~/aspects-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ This section explains how to use aspects within your project.
|[Create an aspect](aspects-create.md)|Create an aspect with the `IAspect` interface.|
|[Aspect source generation](aspects-source-generation.md)|Use aspect source generators.|

## Further information
## Additional resources

* [`IAspect` API documentation](xref:Unity.Entities.IAspect)
13 changes: 5 additions & 8 deletions Documentation~/components-buffer-reuse.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
# Reuse a dynamic buffer for multiple entities

If all entities of an `Entities.ForEach` need the same buffer, you can get that buffer as a local variable on the main thread above the `Entities.ForEach`.
If all entities of an [`IJobEntity`](iterating-data-ijobentity.md) need the same buffer, you can get that buffer as a local variable on the main thread before scheduling the job.

The following code sample shows how to use the same dynamic buffer for multiple entities. It assumes a dynamic buffer called `MyElement` exists and another Component exists called `OtherComponent`.
The following code example shows how to use the same dynamic buffer for multiple entities. It assumes a dynamic buffer called `MyElement` exists and another component exists called `OtherComponent`.

```c#
public void DynamicBufferExample(Entity e)
{
var myBuff = EntityManager.GetBuffer<MyElement>(e);

Entities.ForEach((in OtherComponent component) => {
// ... use myBuff
}).Schedule();
var myBuff = SystemAPI.GetBuffer<MyElement>(e);
new MyJobEntity{MyBuffer = myBuf}.Schedule();
}
```

> [!NOTE]
> If you use `ScheduleParallel`, be aware that you can't write to the dynamic buffer in parallel. You can however use an `EntityCommandBuffer.ParallelWriter` to record changes in parallel.
> If you use `ScheduleParallel`, you can't write to the dynamic buffer in parallel. Instead, you can use an `EntityCommandBuffer.ParallelWriter` to record changes in parallel. However, any [structural changes](concepts-structural-changes.md) invalidate the buffer.
## Additional resources

Expand Down
26 changes: 15 additions & 11 deletions Documentation~/components-enableable-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@

You can use enableable components on [IComponentData](xref:Unity.Entities.IComponentData) and [IBufferElementData](xref:Unity.Entities.IBufferElementData) components to disable or enable individual components on an entity at runtime. To make components enableable, inherit them from [IEnableableComponent](xref:Unity.Entities.IEnableableComponent).

Enableable components are ideal for states that you expect to change frequently and unpredictably, or where the number of state permutations are high on a frame-by-frame basis. [Adding](components-add-to-entity.md) and [removing components](components-remove-from-entity.md) is the preferable way to manage components for low-frequency state changes, where you expect the state to persist for many frames.
Enableable components are ideal for states that you expect to change often and unpredictably, or where the number of state permutations are high on a frame-by-frame basis. [Adding](components-add-to-entity.md) and [removing components](components-remove-from-entity.md) is the preferable way to manage components for low-frequency state changes, where you expect the state to persist for many frames.

You can also use enableable components instead of a set of zero-size [tag components](components-tag.md) to represent entity states. This reduces the number of unique entity archetypes, and encourages better [chunk](concepts-archetypes.md#archetype-chunks) usage to reduce memory consumption.

## Structural changes

Enableable components don't create [structural changes](concepts-structural-changes.md), unlike adding and removing components. ECS treats a disabled component as though the entity doesn't have that component when determining if an entity matches an [entity query](systems-entityquery.md). This means that an entity with a disabled component doesn't match a query that requires the component, and matches a query that excludes the component, assuming it meets all other query criteria.

## Tag component alternative
The semantics of existing component operations don't change. `EntityManager` considers an entity with a disabled component to still have the component.

You can also use enableable components instead of a set of zero-size [tag components](components-tag.md) to represent entity states. This reduces the number of unique entity archetypes, and encourages better [chunk](concepts-archetypes.md#archetype-chunks) utilization to reduce memory consumption.
For example, if component `T` is disabled on entity `E` these methods do the following:

## Enabled component semantics
|**Method**|**Outcome**|
|---|---|
|`HasComponent<T>(E)` |Returns true.|
|`GetComponent<T>(E)` |Returns component `T`’s current value.|
|`SetComponent<T>(E,value)`| Updates the component `T`’s value.|
|`RemoveComponent<T>(E)`| Removes component `T` from `E`.|
|`AddComponent<T>(E)`| Quietly does nothing, because the component already exists.|

The semantics of existing component operations don't change. `EntityManager` considers an entity with a disabled component to still have the component.
## Additional resources

Specifically, if component `T` is disabled on entity `E`:
* `HasComponent<T>(E)` returns true.
* `GetComponent<T>(E)` returns the component’s current value.
* `SetComponent<T>(E,value)` updates the component’s value.
* `RemoveComponent<T>(E)` removes the component from E.
* `AddComponent<T>(E)` quietly does nothing, because the component already exists.
* [Use enableable components](components-enableable-use.md)
* [Look up arbitrary data](systems-looking-up-data.md)
Loading

0 comments on commit 2d5a2ab

Please sign in to comment.