Skip to content

Commit 4cc372c

Browse files
author
gamecode-ci
committed
Release 21
1 parent d7e17dd commit 4cc372c

File tree

144 files changed

+13375
-1716
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+13375
-1716
lines changed

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,15 @@ Samples/Assets/StreamingAssets/TestResults.xml.meta
4545
Samples/Assets/StreamingAssets/TestResults.xml
4646
Samples/Assets/StreamingAssets/PerformanceTestResults.json.meta
4747
Samples/Assets/StreamingAssets/PerformanceTestResults.json
48+
Samples/Assets/EntityCache.meta
49+
Samples/Assets/StreamingAssets/EntityCache
50+
Samples/Assets/StreamingAssets/EntityCache.meta
51+
Samples/Assets/EntityCache
52+
*~master*
53+
*~HEAD*
54+
55+
artifacts
56+
57+
.Editor
58+
.UnityLauncher.Editor
59+

Documentation~/injection.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,72 @@ Injection is on its way out, it is not recommended to use to the `[Inject]` attr
66
* ComponentDataFromEntity injection is replaced by `(Job)ComponentSystem.GetComponentDataFromEntity`.
77
* Injecting other systems is replaced by `(Job)ComponentSystem.World.GetOrCreateManager`.
88

9+
```cs
10+
class MySystem : JobComponentSystem
11+
{
12+
// Deprecated Injection-based setup. Moved to a ComponentGroup.
13+
//public struct Group
14+
//{
15+
// // ComponentDataArray lets us access IComponentData
16+
// public ComponentDataArray<Position> Position;
17+
18+
// [ReadOnly]
19+
// public ComponentDataArray<Velocity> Velocity;
20+
21+
// // The Length can be injected for convenience as well
22+
// public int Length;
23+
//}
24+
//[Inject] private Group m_Group;
25+
26+
struct MoveJob : IJobProcessComponentData<Position, Velocity>
27+
{
28+
public float dt;
29+
30+
public void Execute(ref Position position, [ReadOnly] ref Velocity velocity)
31+
{
32+
position = new Position { position.value + velocity.value * dt };
33+
}
34+
}
35+
36+
protected override JobHandle OnUpdate(JobHandle inputDeps)
37+
{
38+
var job = new MoveJob
39+
{
40+
dt = Time.deltaTime
41+
};
42+
43+
return job.Schedule(this, inputDeps);
44+
}
45+
}
46+
```
47+
48+
```cs
49+
class PositionSystem : JobComponentSystem
50+
{
51+
private OtherSystem m_SomeOtherSystem;
52+
53+
protected override void OnCreateManager()
54+
{
55+
m_SomeOtherSystem = World.GetOrCreateManager<OtherSystem>();
56+
}
57+
}
58+
```
59+
60+
```cs
61+
class PositionSystem : JobComponentSystem
62+
{
63+
//[Inject] ComponentDataFromEntity<Position> m_Positions;
64+
65+
protected override JobHandle OnUpdate(JobHandle inputDeps)
66+
{
67+
// Moved to a local variable in OnUpdate (must be called every frame)
68+
var positions = GetComponentDataFromEntity<Position>();
69+
70+
...
71+
}
72+
}
73+
```
74+
975
# Injection
1076

1177
Injection allows your system to declare its dependencies, while those dependencies are then automatically injected into the injected variables before `OnCreateManager`, `OnDestroyManager`, and `OnUpdate`.

README.md

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,78 @@
11
# Welcome
2-
Welcome to the Entity Component System and C# Job System samples repository!
2+
Welcome to the DOTS Samples repository!
33

44
Here you can find the resources required to start building with these new systems today.
55

6-
We have also provided a new forum where you can find more information and share your experiences with these new systems.
6+
We have also provided a forum where you can find more information and share your experiences with these new systems.
77

88
[Click here to visit the forum](https://unity3d.com/performance-by-default)
99

10-
## What is in the build
11-
We have been working on a new high performance multithreaded system, that will make it possible for games to fully utilise the multicore processors available today without heavy programming headache. This is possible thanks to the new Entity Component System which provides a way to write performant code by default. Paired with the C# Job System and a new math-aware backend compiler technology named Burst. Unity can produce highly optimised code for the particular capabilities of the platform you’re compiling for.
10+
## What is the Unity Data Oriented Tech Stack?
11+
We have been working on a new high performance multithreaded system, that will make it possible for games to fully utilise the multicore processors available today without heavy programming headache. The Data Oriented Tech Stack includes the following major systems:
1212

13-
[Download the beta build required here](https://unity3d.com/unity/beta-download)
13+
* The **Entity Component System** provides a way to write performant code by default.
14+
* The **C# Job System** provides a way to run your game code in parallel on multiple CPU cores
15+
* The **Burst compiler** a new math-aware, backend compiler tuned to produce highly optimized machine code.
16+
17+
With these systems, Unity can produce highly optimised code for the particular capabilities of the platform you’re compiling for.
1418

1519
## Entity Component System
16-
Offers a better approach to game design that allows you to concentrate on the actual problems you are solving: the data and behavior that make up your game. It leverages the C# Job System and Burst Compiler enabling you to take full advantage of today's multicore processors. By moving from object-oriented to data-oriented design it will be easier for you to reuse the code and easier for others to understand and work on it
20+
The Entity Component System offers a better approach to game design that allows you to concentrate on the actual problems you are solving: the data and behavior that make up your game. It leverages the C# Job System and Burst Compiler enabling you to take full advantage of today's multicore processors. Moving from object-oriented to data-oriented design makes it easier for you to reuse the code and easier for others to understand and work on it.
1721

18-
The Entity Component System ships as an experimental package in 2018.1 and later, and we’ll continue to develop and release new versions of the package in the 2018.x cycle. It is important to stress that the Entity Component System is not production ready
22+
The Entity Component System ships as an experimental package that currently supports Unity 2018.3 and later. It is important to stress that the Entity Component System is not production ready.
1923

2024
## C# Job System
21-
The new C# Job System takes advantage of multiple cores in a safe and easy way. Easy, as it’s designed to open this approach up to user scripts and allows users to write safe, fast, jobified code while providing protection from some of the pitfalls of multi-threading such as race conditions.
25+
The new C# Job System takes advantage of multiple cores in a safe and easy way. Easy, as it’s designed to open this approach up to user scripts and allows you to write safe, fast, jobified code while providing protection from some of the pitfalls of multi-threading such as race conditions.
2226

23-
The C# Job System ships in 2018.1.
27+
The C# Job System is a built-in module included in Unity 2018.1+.
2428

2529
[Further sample projects on the C# Job System can be found here](https://github.com/stella3d/job-system-cookbook)
2630

2731
## Burst
28-
Burst is a new LLVM based math-aware backend Compiler Technology makes things easier for you. It takes the C# jobs and produces highly-optimized code taking advantage of the particular capabilities of the platform you’re compiling for.
32+
Burst is a new LLVM-based, math-aware backend compiler. It compiles C# jobs into highly-optimized machine code that takes advantage of the particular capabilities of the platform you’re compiling for.
2933

30-
Burst ships as an experimental package in 2018.1, and we’ll continue to develop and release new versions of the package in the 2018.x cycle. For the current package release, Burst only works in the Unity editor. It is important to stress that Burst is not production ready
34+
Burst is an experimental package that currently supports Unity 2018.3 and later. It is important to stress that Burst is not production ready.
3135

3236
[Watch Joachim Ante present these new systems at Unite Austin](https://youtu.be/tGmnZdY5Y-E)
3337

3438
## Samples
3539
To help you get started, we have provided this repository of examples for learning how to to write systems at scale.
3640

37-
### The TwoStickShooter project
38-
This is a set of projects that demonstrates different approaches with the MonoBehaviour, Hybrid Entity Component System and Pure Entity Component System. This is a good starting point to understand how the Entity Component System paradigm works.
41+
### HelloECS
42+
This is a set of projects demonstrate the absolute basics of the Unity ECS architecture:
43+
44+
* **HelloCube_01_ForEach** — creates a pair of rotating cubes. This example demonstrates the separation of data and behavior with System and Components.
45+
* **HelloCube_02_IJobProcessComponentData** — builds on HelloCube_01_ForEach, using a Job-based system. Systems based on IJobProcessComponentData are the recommended approach and can take advantage of available CPU cores.
46+
* **HelloCube_03_IJobChunk** — shows how to write a System using IJobChunk. IJobChunk is the recommended method for processing Components for cases more complex than a simple IJobProcessComponentData can describe.
47+
* **HelloCube_04_SubScene** — demonstrates how to create and modify Entities using SubScenes in the Unity editor.
48+
* **HelloCube_05_SpawFromMonoBehaviour** — demonstrates how to spawn multiple Entities from a MonoBehaviour function based on a Prefab GameObject.
49+
* **HelloCube_04_Spawner** — demonstrates how to spawn multiple Entities at runtime using a spawning Job in a System.
50+
51+
### Boids
52+
53+
The Boids example provides a more complex scenario with thousands of Entities. Boids simulates an underwater scene with a shark and schools containing thousands of fish. (It uses the classic Boids flocking algorithm for the schooling fish behavior.)
3954

4055
## Installation guide for blank ECS project
4156

42-
> Note: If you want to have multiple versions of Unity on one machine then you need to follow [these instructions](https://docs.unity3d.com/462/Documentation/Manual/InstallingMultipleVersionsofUnity.html). The manual page is a bit old, in terms of which versions of Unity it describes, but the instructions are otherwise correct.
57+
1. Open the Unity Editor (2019.1b4 or later)
58+
2. Create a new Project.
59+
3. Open the Package Manager (menu: **Window** > **Package Manager**).
60+
4. Click the **Advanced** button at the top of the window and turn on the **Show preview packages** option.
61+
5. Add the following packages to the project:
4362

44-
* Make sure you have installed the required version of [Unity](#what-is-in-the-build).
45-
* Open Unity on your computer.
46-
* Create a new Unity project and name it whatever you like.
63+
* Entities
64+
* Hybrid.Renderer
4765

48-
> Note: In Unity 2018.1 the new Project window is a little different because it offers you more than just 2D and 3D options.
66+
Adding the Entities package to your Project also adds the following packages:
67+
68+
* Burst
69+
* Collections
70+
* Jobs
71+
* Mathematics
4972

50-
* Once the project is created then navigate in the Editor menu to: __Edit__ > __Project Settings__ > __Player__ > __Other Settings__ then set __Scripting Runtime Version__ to: __4.x equivalent__. This will cause Unity to restart.
51-
* Then navigate to __Window__ > __Package Manager__ and select the __Entities__ package and install it. This is also where you update the package to a newer version.
73+
**Note:** You can use the [Unity Hub](https://unity3d.com/get-unity/download) to install multiple versions of Unity on the same computer.
5274

5375
## Documentation
54-
Looking for information on how to get started or have specific questions? Visit our ECS & Job system documentation
76+
Looking for information on how to get started or have specific questions? Visit our ECS & Job system documentation.
5577

5678
[Go to documentation](Documentation~/index.md)

ReleaseNotes.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,58 @@
1+
# 0.0.23
2+
## New Features
3+
* Added ComponentGroup versions of AddChunkComponentData, RemoveChunkComponentData and AddSharedComponentData. Also optimized the ComponentGroup versions of AddComponent and RemoveComponent.
4+
These can now be used to add and remove components to all the chunks/entities in an ComponentGroup. For components that don't change the layout of chunks (Tag, Shared and Chunk components)
5+
these functions will take an optimized path that migrates the chunks to new archetypes without copying the component data.
6+
* Added new transform-related components as part of redesign (in progress)
7+
* `CompositeRotation`
8+
* `PreRotation`
9+
* `PreRotationEulerXYZ``ZYX`
10+
* `RotationEulerXYZ``ZYX`
11+
* `RotationPivot`
12+
* `RotationPivotTranslation`
13+
* `CompositeScale`
14+
* `Scale` (now for uniform scale)
15+
* `ScalePivot`
16+
* `ScalePivotTranslation`
17+
18+
## Upgrade guide
19+
20+
## Changes
21+
* 2018.3 support has been dropped. Please ensure you are on 2019.1+ if you want to keep getting new updates
22+
* BarrierSystem renamed to EntityCommandBufferSystem
23+
* Subtractive renamed to Exclude
24+
* `[RequireSubtractiveComponent]` renamed to `[ExcludeComponent]`
25+
* ComponentType.Create renamed to ComponentType.ReadWrite
26+
* Transform-related component names changes
27+
* `Position`-\>`Translation`
28+
* `Scale`-\>`NonUniformScale`
29+
* Attach, Attached components removed. (No transform hierarchy)
30+
* `ComponentDataArray`, `BufferArray`, `SharedComponentDataArray`, and `EntityArray` have been deprecated. Please use `ForEach`, `IJobProcessComponentData`, `IJobChunk`, and `ComponentGroup` APIs to access component data.
31+
* `[Inject]` has been deprecated. See [the Injection documentation](Documentation/content/injection.md) for more information.
32+
* Component system update ordering is now hierarchical. A forthcoming document will cover this feature in detail. Key changes:
33+
* Added `ComponentSystemGroup` class, representing a group of systems (and system groups) to update in a fixed order.
34+
* The following `ComponentSystemGroup`s are added to the Unity player loop by default:
35+
* `InitializationSystemGroup` (in the `Initialization` phase)
36+
* `SimulationSystemGroup` (in the `FixedUpdate` phase)
37+
* `PresentationSystemGroup` (in the `Update` phase)
38+
* Each of the default system groups contains a pair of `BarrierSystem`s which run at the beginning and end of that group (e.g. `EndSimulationBarrier`).
39+
* `EndFrameBarrier` has been removed; use the `End` barrier in the appropriate system group instead.
40+
* Use `[UpdateInGroup]` to specify which `ComponentSystemGroup` a system should be added to during default world initialization.
41+
* If omitted, systems are added to the `SimulationSystemGroup` by default (and will thus update during the FixedUpdate phase).
42+
* Built-in ECS systems have been pre-assigned to the appropriate groups.
43+
* Use `[UpdateBefore]` and `[UpdateAfter]` to specify relative ordering of systems within their common `ComponentSystemGroup`.
44+
* Ordering relative to systems in different system groups is implicit from the group hierarchy; explicitly specifying this ordering triggers a warning and will be ignored.
45+
* Added `ICustomBootstrap` interface to allow applications to partially/fully override the default world initialization process, support multiple Worlds, etc.
46+
* MoveEntitiesFrom no longer remaps Entity references.
47+
48+
## Fixes
49+
* Fixed bug causing incorrect read dependency error on Unity.Entities.Entity
50+
* ComponentSystem.GetComponentGroup(...) will no longer treat two queries with the same component types and access modes, but in a different order as different groups.
51+
52+
## Known issues
53+
54+
55+
156
# 0.0.22
257
## New Features
358

Samples/Assets/Advanced/Boids/SampleAssets/TestBoidFish 1.prefab

Lines changed: 27 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ GameObject:
1212
- component: {fileID: 114569172725802478}
1313
- component: {fileID: 114080190520665040}
1414
- component: {fileID: 114800422694471510}
15-
- component: {fileID: 114577371648038814}
16-
- component: {fileID: 114736019212762124}
17-
- component: {fileID: 114127017546310814}
18-
- component: {fileID: 114793043710192570}
19-
- component: {fileID: 114539270869549400}
20-
- component: {fileID: 114503461256266106}
15+
- component: {fileID: 5960292710943834345}
2116
m_Layer: 0
2217
m_Name: TestBoidFish 1
2318
m_TagString: Untagged
@@ -67,6 +62,7 @@ MonoBehaviour:
6762
mesh: {fileID: 4300000, guid: 49a87e3402ce60f4eba9b0498164bdd5, type: 3}
6863
material: {fileID: 2100000, guid: a775bbb190ee2594d99a10542e99e940, type: 2}
6964
subMesh: 0
65+
layer: 0
7066
castShadows: 0
7167
receiveShadows: 0
7268
--- !u!114 &114800422694471510
@@ -82,12 +78,13 @@ MonoBehaviour:
8278
m_Name:
8379
m_EditorClassIdentifier:
8480
m_SerializedData:
85-
cellRadius: 8
86-
separationWeight: 1
87-
alignmentWeight: 1
88-
targetWeight: 2
89-
obstacleAversionDistance: 30
90-
--- !u!114 &114577371648038814
81+
CellRadius: 8
82+
SeparationWeight: 1
83+
AlignmentWeight: 1
84+
TargetWeight: 2
85+
ObstacleAversionDistance: 30
86+
MoveSpeed: 20
87+
--- !u!114 &5960292710943834345
9188
MonoBehaviour:
9289
m_ObjectHideFlags: 0
9390
m_CorrespondingSourceObject: {fileID: 0}
@@ -96,85 +93,28 @@ MonoBehaviour:
9693
m_GameObject: {fileID: 1501737747371270}
9794
m_Enabled: 1
9895
m_EditorHideFlags: 0
99-
m_Script: {fileID: 11500000, guid: 2a3df74967fd46d88513d53354d812b0, type: 3}
100-
m_Name:
101-
m_EditorClassIdentifier:
102-
--- !u!114 &114736019212762124
103-
MonoBehaviour:
104-
m_ObjectHideFlags: 0
105-
m_CorrespondingSourceObject: {fileID: 0}
106-
m_PrefabInstance: {fileID: 0}
107-
m_PrefabAsset: {fileID: 0}
108-
m_GameObject: {fileID: 1501737747371270}
109-
m_Enabled: 1
110-
m_EditorHideFlags: 0
111-
m_Script: {fileID: 11500000, guid: 18a96475c2a6546f98923f5efce65c45, type: 3}
112-
m_Name:
113-
m_EditorClassIdentifier:
114-
--- !u!114 &114127017546310814
115-
MonoBehaviour:
116-
m_ObjectHideFlags: 0
117-
m_CorrespondingSourceObject: {fileID: 0}
118-
m_PrefabInstance: {fileID: 0}
119-
m_PrefabAsset: {fileID: 0}
120-
m_GameObject: {fileID: 1501737747371270}
121-
m_Enabled: 1
122-
m_EditorHideFlags: 0
123-
m_Script: {fileID: 11500000, guid: b1d6fa11d99284d278a672af9ed089be, type: 3}
124-
m_Name:
125-
m_EditorClassIdentifier:
126-
m_SerializedData:
127-
speed: 20
128-
--- !u!114 &114793043710192570
129-
MonoBehaviour:
130-
m_ObjectHideFlags: 0
131-
m_CorrespondingSourceObject: {fileID: 0}
132-
m_PrefabInstance: {fileID: 0}
133-
m_PrefabAsset: {fileID: 0}
134-
m_GameObject: {fileID: 1501737747371270}
135-
m_Enabled: 1
136-
m_EditorHideFlags: 0
137-
m_Script: {fileID: 11500000, guid: 0af0db853e732453799566a0e597993c, type: 3}
138-
m_Name:
139-
m_EditorClassIdentifier:
140-
m_SerializedData:
141-
Value:
142-
x: 0
143-
y: 0
144-
z: 0
145-
--- !u!114 &114539270869549400
146-
MonoBehaviour:
147-
m_ObjectHideFlags: 0
148-
m_CorrespondingSourceObject: {fileID: 0}
149-
m_PrefabInstance: {fileID: 0}
150-
m_PrefabAsset: {fileID: 0}
151-
m_GameObject: {fileID: 1501737747371270}
152-
m_Enabled: 1
153-
m_EditorHideFlags: 0
154-
m_Script: {fileID: 11500000, guid: 345a91954f2ba4779ae83b4fcf75bef6, type: 3}
96+
m_Script: {fileID: 11500000, guid: 6851b6711fc654d54b6566c5eae03737, type: 3}
15597
m_Name:
15698
m_EditorClassIdentifier:
15799
m_SerializedData:
158100
Value:
159-
value:
101+
c0:
160102
x: 0
161103
y: 0
162104
z: 0
163-
w: 1
164-
--- !u!114 &114503461256266106
165-
MonoBehaviour:
166-
m_ObjectHideFlags: 0
167-
m_CorrespondingSourceObject: {fileID: 0}
168-
m_PrefabInstance: {fileID: 0}
169-
m_PrefabAsset: {fileID: 0}
170-
m_GameObject: {fileID: 1501737747371270}
171-
m_Enabled: 1
172-
m_EditorHideFlags: 0
173-
m_Script: {fileID: 11500000, guid: f4106573d26a4a478fc47ec4c6ee5461, type: 3}
174-
m_Name:
175-
m_EditorClassIdentifier:
176-
m_SerializedData:
177-
Value:
178-
x: 0
179-
y: 0
180-
z: 0
105+
w: 0
106+
c1:
107+
x: 0
108+
y: 0
109+
z: 0
110+
w: 0
111+
c2:
112+
x: 0
113+
y: 0
114+
z: 0
115+
w: 0
116+
c3:
117+
x: 0
118+
y: 0
119+
z: 0
120+
w: 0

0 commit comments

Comments
 (0)