Skip to content

Commit d6b6417

Browse files
committed
Release 1
0 parents commit d6b6417

File tree

892 files changed

+94059
-0
lines changed

Some content is hidden

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

892 files changed

+94059
-0
lines changed

.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
**/Library/
2+
**/Temp/
3+
**/obj/
4+
5+
**/.vscode
6+
**/.vs
7+
**/.editorconfig
8+
9+
**/Assets/Plugins/*
10+
**/Assets/Plugins.meta
11+
12+
*.idea
13+
*.csproj
14+
*.sln
15+
*.suo
16+
*.userprefs
17+
*.app
18+
*.VC.*
19+
.DS_Store
20+
*~
21+
*.swp
22+
23+
.vs/
24+
build/*
25+
TwoStickShooter/Pure/Library/AnnotationManager

CONTRIBUTIONS.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Contributions
2+
3+
## If you are interested in contributing, here are some ground rules:
4+
* Entity Component System is based on some [principles](Documentation/content/ecs_principles_and_vision.md). Read and apply them to your contributions
5+
* Follow naming & style conventions in the project
6+
* Everything must have test coverage. (PRs with insufficient test coverage will be rejected)
7+
* Pull requests must be made against master (Not stable, which is the default)
8+
9+
## All contributions are subject to the [Unity Contribution Agreement(UCA)](https://unity3d.com/legal/licenses/Unity_Contribution_Agreement)
10+
By making a pull request, you are confirming agreement to the terms and conditions of the UCA, including that your Contributions are your original creation and that you have complete right and authority to make your Contributions.
11+
12+
## Once you have a change ready following these ground rules. Simply make a pull request in Github
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# How to optimize for the Burst compiler
2+
3+
* Use Unity.Mathematics, Burst natively understands the math operations and is optimized for it.
4+
* Avoid branches. Use math.min, math.max, math.select instead.
5+
* For jobs that have to be highly optimized, ensure that each job uses every single variable in the IComponentData. If some variables in an IComponentData is not being used, move it to a separate component. That way the unused data will not be loaded into cache lines when iterating over Entities.

Documentation/content/custom_job_types.md

Lines changed: 356 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# ECS concepts
2+
3+
If you are familiar with [Entity-component-system](https://en.wikipedia.org/wiki/Entity%E2%80%93component%E2%80%93system) 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:
4+
5+
### Entity → Entity
6+
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!).
8+
9+
You can add Components to Entities; similar to how you add Components to GameObjects.
10+
11+
### Component → ComponentData
12+
13+
We are introducing a new high-performance ComponentType.
14+
15+
```
16+
struct MyComponent: IComponentData
17+
{}
18+
```
19+
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.
21+
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.
23+
24+
### System → ComponentSystem
25+
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: 377 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# ECS principles and vision
2+
3+
## Performance by default
4+
5+
We want to make it simple to create efficient machine code for all platforms.
6+
7+
We measure ourselves against the performance that can be achieved in C++ with handwritten highly optimized [simd](https://en.wikipedia.org/wiki/SIMD) intrinsics.
8+
9+
We are using a combination of compiler technology (Burst), containers (Unity.Collections), data layout of components (ECS) to make it easy to write efficient code by default.
10+
11+
* Multicore - TODO
12+
* SIMD - TODO
13+
* Data layout & iteration - TODO
14+
* Instantiation speed - TODO
15+
16+
At Unite Austin we showcased a demo with 100.000 individual units in a massive battle simulation running at 60 FPS. All game code was running multicore.
17+
[See ECS performance demo [Video]](https://www.youtube.com/watch?v=0969LalB7vw)
18+
19+
## Simple
20+
21+
Writing [performant](https://en.wiktionary.org/wiki/performant) code must be simple. We believe that we can make writing fast code as simple as __MonoBehaviour.Update__.
22+
23+
> Note: To set expectations right, we think we still have some ways to go to achieve this goal.
24+
25+
## One way of writing code
26+
27+
We want to define a single way of writing game code, editor code, asset pipeline code, engine code. We believe this creates a simpler tool for our users, and more ability to change things around.
28+
29+
Physics is a great example. Currently Physics is a black box solution. In practice many developers want to tweak the simulation code to fit it to their games needs. If physics engine code was written the same way as game code using ECS, it would make it easy to plug your own simulation code between existing physics simulation stages or take full control.
30+
31+
Another example, lets imagine you want to make a heavily moddable game.
32+
33+
If our import pipeline is implemented as a set of __ComponentSystems__. And we have some FBX import pipeline code that is by default used in the asset pipeline to import and postprocess an FBX file. (Mesh is baked out and FBX import code used in the editor.)
34+
35+
Then it would be easy to configure the Package Manager that the same FBX import and postprocessing code could be used in a deployed game for the purposes of modding.
36+
37+
We believe this will, at the foundation level, make Unity significantly more flexible than it is today.
38+
39+
## Networking
40+
41+
We want to define one simple way of writing all game code. When following this approach, your game can use one of three network architectures depending on what type of game you create.
42+
43+
We are focused on providing best of class network engine support for hosted games. Using the recently acquired [Multiplay.com](http://Multiplay.com) service we offer a simple pipeline to host said games.
44+
45+
* FPS - Simulation on the server
46+
* RTS - Deterministic lock step simulation
47+
* Arcade games - GGPO
48+
TODO: More detail / Links (maybe a game type example of what you would use each network architecture for)
49+
50+
## Determinism
51+
52+
Our build pipeline must be [deterministic](https://en.wikipedia.org/wiki/Deterministic_algorithm). Users can choose if all simulation code should run deterministically.
53+
54+
This is important for networking, replay features and even advanced debugging tools.
55+
56+
We will leverage our Burst compiler to produce exact floating point math between different platforms. Imagine a linux server & iOS device running the same floating point math code. This is useful for many scenarios particularly for connected games, but also debugging, replay etc.
57+
58+
TODO - link/explain the floating math problem a little before the burst compiler solved it (so those who are unaware of the fp math issue get the point.) Is this a good reference I'm not sure: https://hal.archives-ouvertes.fr/file/index/docid/281429/filename/floating-point-article.pdf
59+
60+
## Sandbox
61+
62+
Unity is a sandbox, safe and simple.
63+
64+
We provide great error messages when API's are used incorrectly, we never put ourselves in a position where incorrect usage results in a crash and that is by design (as opposed to a bug we can quickly fix).
65+
66+
A good example of sandbox behaviour is that our C# job system guarantees that none of your C# job code has race conditions. We deterministically check all possible race conditions through a combination of static code analysis & runtime checks. We give you well written error messages about any race conditions right away. So you can trust that your code works and feel safe that even developers who write multithreaded game code for the first time will do it right.
67+
68+
## Tiny
69+
70+
We want Unity to be usable for all content from < 50kb executables + content, to gigabyte sized games. We want Unity to load in less than 1 second for small content.
71+
72+
## Iteration time
73+
74+
We aim to keep iteration time for any common operations in a large project folder below 500ms.
75+
76+
As an example we are working on rewriting the C# compiler to be fully incremental with the goal of:
77+
78+
> When changing a single .cs file in a large project. The combined compile and hot reload time should be less than 500ms.
79+
80+
## Our code comes with full unit test coverage
81+
82+
We believe in shipping robust code from the start. We use unit tests to prove that our code works correctly when it is written and committed by the developer. Tests are shipped as part of the packages.
83+
84+
## Evolution
85+
86+
We are aware that we are proposing a rather large change in how to write code. From MonoBehaviour.Update to ComponentSystem & using jobs.
87+
88+
We believe that ultimately the only thing that convinces a game developer is trying it and seeing the result with your own eyes, on your own game.
89+
90+
Thus it is important that applying the ECS approach on an existing project should be easy and quick to do. Our goal is that within 30 minutes a user can, in a large project, change some code from MonoBehaviour.Update to ComponentSystem and have a successful experience optimizing his game code.
91+
92+
## Packages
93+
94+
We want the majority of our engine code to be written in C# and deployed in a Package. All source code is available to all Unity Pro customers.
95+
96+
We want a rapid feedback loop with customers, given that we can push code and get feedback on something quickly in a package without destabilizing other parts.
97+
98+
Previously most of our engine code was written in C++, which creates a disconnect with how our customers write code and how programmers at Unity write code. Due to the Burst compiler tech & ECS, we can achieve better than C++ with C# code and as a result we can all write code exactly the same way.
99+
100+
## Collaboration
101+
102+
We believe Unity users and Unity developers are all on the same team. Our purpose is to help all Unity users create the best game experiences faster, in higher quality, and with great performance.
103+
104+
We believe every feature we develop must be developed with real scenarios and real production feedback early on. The Package Manager facilitates that.
105+
106+
For those in the community that want to contribute engine code, we aim to make that easy by working directly on the same code repositories that contributors can commit to as well. Through well defined principles and full test coverage of all features, we hope to keep the quality of contributions high as well.
107+
108+
The source code repositories will be available for all Unity Pro Customers.
109+
110+
## Transparency
111+
112+
We believe in transparency. We develop our features in the open, we actively communicate on both forum and blogs. We reserve time so each developer can spend time with customers and understand our users pain points.
113+

0 commit comments

Comments
 (0)