Skip to content

Commit 4af3b83

Browse files
committed
Release 7
1 parent 5441f24 commit 4af3b83

File tree

640 files changed

+38910
-87
lines changed

Some content is hidden

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

640 files changed

+38910
-87
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ TwoStickShooter/Pure/Library/AnnotationManager
3131
!PackageRepos/ECSJobDemos/UnstablePrototypes/Asteriods/Assets/Packages/Unity.Multiplayer/Plugins/gamesocket.native.pdb
3232

3333
*.pyc
34+
StreamingAssets.meta

Documentation/content/ecs_concepts.md

Lines changed: 100 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,112 @@
11
# ECS concepts
22

3-
If you are familiar with [Entity-component-system](https://en.wikipedia.org/wiki/Entity%E2%80%93component%E2%80%93system) (ECS) concepts, you might see the potential for naming conflicts with Unity's existing __GameObject__/__Component__ setup. Below is a list comparing how ECS concepts map to Unity's implementation:
3+
If you are familiar with [Entity-component-system](https://en.wikipedia.org/wiki/Entity%E2%80%93component%E2%80%93system) (ECS) concepts, you might see the potential for naming conflicts with Unity's existing __GameObject__/__Component__ setup.
44

5-
### Entity → Entity
5+
The purpose of this page is:
6+
1. Clarify and disambiguate the concepts as used in the ECS.
7+
2. Provide a brief introduction to each concept as an entry point to a new user.
68

7-
Unity did not have an __Entity__ to begin with, so the structure is simply named after the concept. Entities are like super lightweight GameObjects, in that they don't do much on their own, and they don't store any data (not even a name!).
9+
### EntityManager
10+
Manages memory and structural changes.
811

9-
You can add Components to Entities; similar to how you add Components to GameObjects.
12+
### ComponentData
13+
Parallel streams of concrete, [blittable](https://docs.microsoft.com/en-us/dotnet/framework/interop/blittable-and-non-blittable-types) data.
1014

11-
### Component → ComponentData
15+
e.g.
1216

13-
We are introducing a new high-performance ComponentType.
17+
| Position | HitPoints |
18+
| ---------- | -----------|
19+
| 64,30 | 69 |
20+
| 58,55 | 70 |
21+
| 95,81 | 81 |
22+
| 10,50 | 19 |
23+
| 36,24 | 38 |
24+
| 67,33 | 40 |
1425

15-
```
16-
struct MyComponent: IComponentData
17-
{}
18-
```
26+
See: [IComponentData in detail](ecs_in_detail.md#icomponentdata)
27+
28+
29+
### Entity
30+
An ID which can be used for indirect component lookups for the purposes of graph traversal.
31+
32+
e.g.
33+
34+
| Entity | Position | HitPoints |
35+
|--- | ---------- | -----------|
36+
|0 | 64,30 | 69 |
37+
|1 | 58,55 | 70 |
38+
|2 | 95,81 | 81 |
39+
|3 | 10,50 | 19 |
40+
|4 | 36,24 | 38 |
41+
|5 | 67,33 | 40 |
42+
43+
See: [Entity in detail](ecs_in_detail.md#entity)
44+
45+
### SharedComponentData
46+
Type of ComponentData where each unique value is only stored once. ComponentData streams are divided into subsets by each value of all SharedComponentData.
47+
48+
e.g. (Mesh SharedComponentData)
49+
50+
__Mesh = RocketShip__
51+
52+
| Position | HitPoints |
53+
| ---------- | -----------|
54+
| 64,30 | 69 |
55+
| 58,55 | 70 |
56+
| 95,81 | 81 |
57+
58+
__Mesh = Bullet__
59+
60+
| Position | HitPoints |
61+
| ---------- | -----------|
62+
| 10,50 | 19 |
63+
| 36,24 | 38 |
64+
| 67,33 | 40 |
65+
66+
See: [SharedComponentData in detail](ecs_in_detail.md#shared-componentdata)
67+
68+
### EntityArchetype
69+
Specific set of ComponentData types and SharedComponentData values which define the subsets of ComponentData streams stored in the EntityManager.
70+
71+
e.g. In the above, there are two EntityArchetypes:
72+
1. Position, HitPoints, Mesh = RocketShip
73+
2. Position, HitPoints, Mesh = Bullet
74+
75+
See: [EntityArchetype in detail](ecs_in_detail.md#entityarchetype)
76+
77+
### ComponentSystem
78+
Where gameplay/system logic/behavior occurs.
79+
80+
See: [ComponentSystem in detail](ecs_in_detail.md#componentsystem)
81+
82+
### World
83+
A unique EntityManager with specific instances of defined ComponenetSystems. Multiple Worlds may exist and work on independent data sets.
84+
85+
See: [World in detail](ecs_in_detail.md#world)
86+
87+
### SystemStateComponentData
88+
A specific type of ComponentData which is not serialized or removed by default when an Entity ID is deleted. Used for internal state and resource management inside a system. Allows you to manage construction and destruction of resources.
89+
90+
See: [SystemStateComponentData in detail](ecs_in_detail.md#systemstatecomponentdata)
91+
92+
### JobComponentSystem
93+
A type of ComponentSystem where jobs are queued independently of the JobComponentSystem's update, in the background. Those jobs are guaranteed to be completed in the same order as the systems.
94+
95+
See: [JobComponentSystem in detail](ecs_in_detail.md#jobcomponentsystem)
96+
97+
### EntityCommandBuffer
98+
A list of structural changes to the data in an EntityManager for later completion. Structural changes are:
99+
1. Adding Component
100+
2. Removing Component
101+
3. Changing SharedComponent value
102+
103+
See: [EntityCommandBuffer in detail](ecs_in_detail.md#entitycommandbuffer)
104+
105+
### Barrier
106+
A type of ComponentSystem, which provides an EntityCommandBuffer. i.e. A specific (synchronization) point in the frame where that EntityCommandBuffer will be resolved.
107+
108+
See: [Barrier in detail](ecs_in_detail.md#barrier)
19109

20-
The __EntityManager__ manages the memory and makes hard guarantees about linear memory access when iterating over a set of Components. It also has zero overhead on a per Entity basis beyond the size of the struct itself.
21110

22-
In order to differentiate it from the existing component types (such as __MonoBehaviours__), the name refers directly to the fact that it only stores data. __ComponentData__ can be added and removed from Entities.
23111

24-
### System → ComponentSystem
25112

26-
There are a lot of "systems" in Unity, so the name includes the umbrella term, "component" as well. __ComponentSystems__ define your game's behavior, and can operate on several types of data: traditional GameObjects and Components, or pure ECS ComponentData and Entity structs.

Documentation/content/ecs_in_detail.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ As you can see, the API is very similar to the entity manager API. In this mode,
419419

420420
Again let's look at the two stick shooter sample to see how this works in practice.
421421

422+
### Barrier
423+
422424
First, a barrier system is declared:
423425

424426
```cs
@@ -462,3 +464,5 @@ ECS ships with the __GameObjectEntity__ component. It is a MonoBehaviour. In __O
462464
TODO: what do you mean by "the GameObjectEntity component creates an Entity with all components on the GameObject" in the sentence above? do you mean all required components that this GameObject should have in that particular case? or is there a pre-defined set of components that will always be added? It's a little unclear.
463465

464466
> Note: for the time being, you must add a GameObjectEntity component on each GameObject that you want to be visible / iterable from the ComponentSystem.
467+
468+
## SystemStateComponentData

Documentation/content/job_system.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,19 @@ public struct MyParallelJob : IJobParallelFor
210210

211211
```C#
212212
var jobData = new MyParallelJob();
213-
jobData.a = 10;
214-
jobData.b = 10;
215-
jobData.result = result;
213+
jobData.a = new NativeArray<float>(new float[] { 1, 2, 3 }, Allocator.TempJob);
214+
jobData.b = new NativeArray<float>(new float[] { 6, 7, 8 }, Allocator.TempJob);
215+
jobData.result = new NativeArray<float>(3, Allocator.TempJob);
216216

217217
// Schedule the job with one Execute per index in the results array and only 1 item per processing batch
218-
JobHandle handle = jobData.Schedule(result.Length, 1);
218+
JobHandle handle = jobData.Schedule(jobData.result.Length, 1);
219219

220220
// Wait for the job to complete
221221
handle.Complete();
222+
223+
jobData.a.Dispose();
224+
jobData.b.Dispose();
225+
jobData.result.Dispose();
222226
```
223227

224228
## Job System tips and troubleshooting
@@ -239,4 +243,4 @@ Due to the lack of [ref returns](https://docs.microsoft.com/en-us/dotnet/csharp/
239243

240244
### Always call `JobHandle.Complete`
241245

242-
Tracing data ownership requires dependencies to complete before the main thread can use them again. This means that it is not enough to check `JobHandle.IsDone`. You must call the method `JobHandle.Complete` to regain ownership of the `NativeContainers` to the main thread. Calling `Complete` also cleans up the state in the jobs debugger. Not doing so introduces a memory leak. This also applies if you schedule new jobs every frame that have a dependency on the previous frame's job.
246+
Tracing data ownership requires dependencies to complete before the main thread can use them again. This means that it is not enough to check `JobHandle.IsDone`. You must call the method `JobHandle.Complete` to regain ownership of the `NativeContainers` to the main thread. Calling `Complete` also cleans up the state in the jobs debugger. Not doing so introduces a memory leak. This also applies if you schedule new jobs every frame that have a dependency on the previous frame's job.

GalacticConquest/Assets/GalacticConquest.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GalacticConquest/Assets/GalacticConquest/Materials.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!21 &2100000
4+
Material:
5+
serializedVersion: 6
6+
m_ObjectHideFlags: 0
7+
m_CorrespondingSourceObject: {fileID: 0}
8+
m_PrefabInternal: {fileID: 0}
9+
m_Name: Green
10+
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
11+
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
12+
m_LightmapFlags: 4
13+
m_EnableInstancingVariants: 1
14+
m_DoubleSidedGI: 0
15+
m_CustomRenderQueue: -1
16+
stringTagMap: {}
17+
disabledShaderPasses: []
18+
m_SavedProperties:
19+
serializedVersion: 3
20+
m_TexEnvs:
21+
- _BumpMap:
22+
m_Texture: {fileID: 0}
23+
m_Scale: {x: 1, y: 1}
24+
m_Offset: {x: 0, y: 0}
25+
- _DetailAlbedoMap:
26+
m_Texture: {fileID: 0}
27+
m_Scale: {x: 1, y: 1}
28+
m_Offset: {x: 0, y: 0}
29+
- _DetailMask:
30+
m_Texture: {fileID: 0}
31+
m_Scale: {x: 1, y: 1}
32+
m_Offset: {x: 0, y: 0}
33+
- _DetailNormalMap:
34+
m_Texture: {fileID: 0}
35+
m_Scale: {x: 1, y: 1}
36+
m_Offset: {x: 0, y: 0}
37+
- _EmissionMap:
38+
m_Texture: {fileID: 0}
39+
m_Scale: {x: 1, y: 1}
40+
m_Offset: {x: 0, y: 0}
41+
- _MainTex:
42+
m_Texture: {fileID: 0}
43+
m_Scale: {x: 1, y: 1}
44+
m_Offset: {x: 0, y: 0}
45+
- _MetallicGlossMap:
46+
m_Texture: {fileID: 0}
47+
m_Scale: {x: 1, y: 1}
48+
m_Offset: {x: 0, y: 0}
49+
- _OcclusionMap:
50+
m_Texture: {fileID: 0}
51+
m_Scale: {x: 1, y: 1}
52+
m_Offset: {x: 0, y: 0}
53+
- _ParallaxMap:
54+
m_Texture: {fileID: 0}
55+
m_Scale: {x: 1, y: 1}
56+
m_Offset: {x: 0, y: 0}
57+
m_Floats:
58+
- _BumpScale: 1
59+
- _Cutoff: 0.5
60+
- _DetailNormalMapScale: 1
61+
- _DstBlend: 0
62+
- _GlossMapScale: 1
63+
- _Glossiness: 0
64+
- _GlossyReflections: 0
65+
- _Metallic: 0
66+
- _Mode: 0
67+
- _OcclusionStrength: 1
68+
- _Parallax: 0.02
69+
- _SmoothnessTextureChannel: 0
70+
- _SpecularHighlights: 0
71+
- _SrcBlend: 1
72+
- _UVSec: 0
73+
- _ZWrite: 1
74+
m_Colors:
75+
- _Color: {r: 0, g: 0.6132076, b: 0.06537688, a: 1}
76+
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

GalacticConquest/Assets/GalacticConquest/Materials/Green.mat.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!21 &2100000
4+
Material:
5+
serializedVersion: 6
6+
m_ObjectHideFlags: 0
7+
m_CorrespondingSourceObject: {fileID: 0}
8+
m_PrefabInternal: {fileID: 0}
9+
m_Name: Grey
10+
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
11+
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
12+
m_LightmapFlags: 4
13+
m_EnableInstancingVariants: 1
14+
m_DoubleSidedGI: 0
15+
m_CustomRenderQueue: -1
16+
stringTagMap: {}
17+
disabledShaderPasses: []
18+
m_SavedProperties:
19+
serializedVersion: 3
20+
m_TexEnvs:
21+
- _BumpMap:
22+
m_Texture: {fileID: 0}
23+
m_Scale: {x: 1, y: 1}
24+
m_Offset: {x: 0, y: 0}
25+
- _DetailAlbedoMap:
26+
m_Texture: {fileID: 0}
27+
m_Scale: {x: 1, y: 1}
28+
m_Offset: {x: 0, y: 0}
29+
- _DetailMask:
30+
m_Texture: {fileID: 0}
31+
m_Scale: {x: 1, y: 1}
32+
m_Offset: {x: 0, y: 0}
33+
- _DetailNormalMap:
34+
m_Texture: {fileID: 0}
35+
m_Scale: {x: 1, y: 1}
36+
m_Offset: {x: 0, y: 0}
37+
- _EmissionMap:
38+
m_Texture: {fileID: 0}
39+
m_Scale: {x: 1, y: 1}
40+
m_Offset: {x: 0, y: 0}
41+
- _MainTex:
42+
m_Texture: {fileID: 0}
43+
m_Scale: {x: 1, y: 1}
44+
m_Offset: {x: 0, y: 0}
45+
- _MetallicGlossMap:
46+
m_Texture: {fileID: 0}
47+
m_Scale: {x: 1, y: 1}
48+
m_Offset: {x: 0, y: 0}
49+
- _OcclusionMap:
50+
m_Texture: {fileID: 0}
51+
m_Scale: {x: 1, y: 1}
52+
m_Offset: {x: 0, y: 0}
53+
- _ParallaxMap:
54+
m_Texture: {fileID: 0}
55+
m_Scale: {x: 1, y: 1}
56+
m_Offset: {x: 0, y: 0}
57+
m_Floats:
58+
- _BumpScale: 1
59+
- _Cutoff: 0.5
60+
- _DetailNormalMapScale: 1
61+
- _DstBlend: 0
62+
- _GlossMapScale: 1
63+
- _Glossiness: 0
64+
- _GlossyReflections: 0
65+
- _Metallic: 0
66+
- _Mode: 0
67+
- _OcclusionStrength: 1
68+
- _Parallax: 0.02
69+
- _SmoothnessTextureChannel: 0
70+
- _SpecularHighlights: 0
71+
- _SrcBlend: 1
72+
- _UVSec: 0
73+
- _ZWrite: 1
74+
m_Colors:
75+
- _Color: {r: 0.6226415, g: 0.6226415, b: 0.6226415, a: 1}
76+
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

GalacticConquest/Assets/GalacticConquest/Materials/Grey.mat.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)