Skip to content

Commit 2880db7

Browse files
Updated documentation
1 parent 1a51c69 commit 2880db7

File tree

1 file changed

+67
-27
lines changed

1 file changed

+67
-27
lines changed

README.md

Lines changed: 67 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,19 @@ It's recommended to build your entire project around these life cycle methods.
5454

5555
<img src="https://raw.githubusercontent.com/jeffreylanters/unity-entity-component-system/master/.github/WIKI/lifecycle.png" width="100%"></br>
5656

57-
## What's in the box?
57+
## Controllers
5858

59-
### Controllers
59+
### Introduction
6060

61-
**Introduction:** The [Controller](#controllers) is the heart of your Application, each Application should consist of just one, commonly named the MainController. The [Controller](#controllers) is the first entry point of the Entity Component System and is the place where all of your [Systems](#systems) and [Services](#services) are registered. Your [Controller](#controllers) should be attached to a Game Object in your scene and will be marked to not be destroyed when switching scenes.
61+
The [Controller](#controllers) is the heart of your Application, each Application should consist of just one, commonly named the MainController. The [Controller](#controllers) is the first entry point of the Entity Component System and is the place where all of your [Systems](#systems) and [Services](#services) are registered. Your [Controller](#controllers) should be attached to a Game Object in your scene and will be marked to not be destroyed when switching scenes.
6262

6363
```csharp
6464
public class MainController : Controller { }
6565
```
6666

67-
**Virtual On Initialize:** The [Controller](#controllers) consists of an OnInitialize virtual method. This method can be overwritten and will be invoked during the very start of your Application. During this cycle properties with the Injected and Asset attribute are being assigned, it is important to invoke the Register method during this cycle since this is the only time in your Application you can register [Systems](#systems) and [Services](#services).
67+
### Virtual On Initialize
68+
69+
The [Controller](#controllers) consists of an OnInitialize virtual method. This method can be overwritten and will be invoked during the very start of your Application. During this cycle properties with the Injected and Asset attribute are being assigned, it is important to invoke the Register method during this cycle since this is the only time in your Application you can register [Systems](#systems) and [Services](#services).
6870

6971
```csharp
7072
public class MainController : Controller {
@@ -77,23 +79,29 @@ public class MainController : Controller {
7779
}
7880
```
7981

80-
**Virtual On Initialized:** The [Controller](#controllers) consists of an OnInitialized virtual method. This method can be overwritten and will be invoked when all [Systems](#systems) and [Services](#services) did initialize, and all the properties with the Injected and Asset attributes are assigned.
82+
### Virtual On Initialized
83+
84+
The [Controller](#controllers) consists of an OnInitialized virtual method. This method can be overwritten and will be invoked when all [Systems](#systems) and [Services](#services) did initialize, and all the properties with the Injected and Asset attributes are assigned.
8185

8286
```csharp
8387
public class MainController : Controller {
8488
public override void OnInitialized () { }
8589
}
8690
```
8791

88-
**Virtual On Update:** The [Controller](#controllers) consists of an OnUpdate virtual method. This method can be overwritten and will be invoked during the Update cycle. This cycle will run once every frame, the Controller's Update is invoked before the [System's](#systems) and [Service's](#services) update cycles.
92+
### Virtual On Update
93+
94+
The [Controller](#controllers) consists of an OnUpdate virtual method. This method can be overwritten and will be invoked during the Update cycle. This cycle will run once every frame, the Controller's Update is invoked before the [System's](#systems) and [Service's](#services) update cycles.
8995

9096
```csharp
9197
public class MainController : Controller {
9298
public override void OnUpdate () { }
9399
}
94100
```
95101

96-
**Enabling Systems:** To enable or disable [Systems](#systems), the [Controller](#controllers) contains of a method EnableSystem which allows [Systems](#systems) to stop their life cycle methods such as OnUpdate, OnPhysics, OnDrawGui and others. You can provide the [System's](#system) type using a generic. Systems are enabled by default.
102+
### Enabling Systems
103+
104+
To enable or disable [Systems](#systems), the [Controller](#controllers) contains of a method EnableSystem which allows [Systems](#systems) to stop their life cycle methods such as OnUpdate, OnPhysics, OnDrawGui and others. You can provide the [System's](#system) type using a generic. Systems are enabled by default.
97105

98106
```csharp
99107
public class MainController : Controller {
@@ -104,7 +112,9 @@ public class MainController : Controller {
104112
}
105113
```
106114

107-
**Checking Whether Systems Are Enabled:** To check whether [Systems](#systems) are enable or disabled, the [Controller](#controllers) contains of a method IsSystemEnabled. Invoking the method will return a boolean informing if the [System](#systems) is enabled or not. You can provide the [System's](#system) type using a generic.
115+
### Checking Whether Systems Are Enabled
116+
117+
To check whether [Systems](#systems) are enable or disabled, the [Controller](#controllers) contains of a method IsSystemEnabled. Invoking the method will return a boolean informing if the [System](#systems) is enabled or not. You can provide the [System's](#system) type using a generic.
108118

109119
```csharp
110120
public class MainController : Controller {
@@ -114,7 +124,9 @@ public class MainController : Controller {
114124
}
115125
```
116126

117-
**Dependency Injection:** The [Controller](#controllers) allows the use of the Injected attribute on properties to automatically assign the values of referenced [Systems](#Systems) and [Services](#Services), making all public methods and properties accessible. These properties are assigned during the OnInitialize cycle and are available for use at the OnInitialized cycle.
127+
### Injection
128+
129+
The [Controller](#controllers) allows the use of the Injected attribute on properties to automatically assign the values of referenced [Systems](#Systems) and [Services](#Services), making all public methods and properties accessible. These properties are assigned during the OnInitialize cycle and are available for use at the OnInitialized cycle.
118130

119131
```csharp
120132
public class MainController : Controller {
@@ -123,7 +135,9 @@ public class MainController : Controller {
123135
}
124136
```
125137

126-
**Assets:** The [Controller](#controllers) allows the use of the Asset attribute on properties to automatically assign the values of referenced Assets. Assets can be assigned on the [Controller](#controllers) instance in your Scene. When assigning using the empty contructor, the property's name will be used for searching the Asset, to find an Asset by it's name, use the string overload. All types of UnityEngine's Object can be used in these fields. These properties are assigned during the OnInitialize cycle and are available for use at the OnInitialized cycle. When an asset is not found, an error is thrown.
138+
### Assets
139+
140+
The [Controller](#controllers) allows the use of the Asset attribute on properties to automatically assign the values of referenced Assets. Assets can be assigned on the [Controller](#controllers) instance in your Scene. When assigning using the empty contructor, the property's name will be used for searching the Asset, to find an Asset by it's name, use the string overload. All types of UnityEngine's Object can be used in these fields. These properties are assigned during the OnInitialize cycle and are available for use at the OnInitialized cycle. When an asset is not found, an error is thrown.
127141

128142
```csharp
129143
public class MainController : Controller {
@@ -132,17 +146,23 @@ public class MainController : Controller {
132146
}
133147
```
134148

135-
**Notes:** While it is recommended to move as much logic into [Services](#services) and [Systems](#systems), it is possible to let your [Controller](#controllers) house any functionality. If you use the [Controller](#controllers) for this purpose, try to keep it down to only Application wide and core functionality.
149+
### Notes
150+
151+
While it is recommended to move as much logic into [Services](#services) and [Systems](#systems), it is possible to let your [Controller](#controllers) house any functionality. If you use the [Controller](#controllers) for this purpose, try to keep it down to only Application wide and core functionality.
136152

137-
### Components
153+
## Components
138154

139-
**Introduction:** [Components](#components) are responsible for housing the data of your entities, and should consist of nothing more than that. All properties should be public and will be accessible to all [Systems](#systems) and [Controllers](#controllers) since there is no need for privates. [Components](#components) should be added to your Entities (GameObjects) in the Scene, an Entity is not limited to one [Components](#components) and can hold as many as needed.
155+
### Introduction
156+
157+
[Components](#components) are responsible for housing the data of your entities, and should consist of nothing more than that. All properties should be public and will be accessible to all [Systems](#systems) and [Controllers](#controllers) since there is no need for privates. [Components](#components) should be added to your Entities (GameObjects) in the Scene, an Entity is not limited to one [Components](#components) and can hold as many as needed.
140158

141159
```csharp
142160
public class MovementComponent : Component<MovementComponent, MovementSystem> { }
143161
```
144162

145-
**Public Properties:** Public properties are the heart of your [Components](#components), and are here to provide data for the [Systems](#systems) to use. Properties can be added to [Components](#components) like in any other class and can consist of any kind of type.
163+
### Public Properties
164+
165+
Public properties are the heart of your [Components](#components), and are here to provide data for the [Systems](#systems) to use. Properties can be added to [Components](#components) like in any other class and can consist of any kind of type.
146166

147167
```csharp
148168
public class MovementComponent : Component<MovementComponent, MovementSystem> {
@@ -153,7 +173,9 @@ public class MovementComponent : Component<MovementComponent, MovementSystem> {
153173
}
154174
```
155175

156-
**Editor Protection:** Sometimes you want to hide properties from the Unity Editor when they are, for example are managed by the [Systems](#systems). By flagging these properties with the Protected attribute, it will no longer shows up in the Unity Editor, but is still accessible by the [Systems](#systems).
176+
### Editor Protection
177+
178+
Sometimes you want to hide properties from the Unity Editor when they are, for example are managed by the [Systems](#systems). By flagging these properties with the Protected attribute, it will no longer shows up in the Unity Editor, but is still accessible by the [Systems](#systems).
157179

158180
```csharp
159181
public class MovementComponent : Component<MovementComponent, MovementSystem> {
@@ -169,31 +191,39 @@ public class MovementComponent : Component<MovementComponent, MovementSystem> {
169191
}
170192
``` -->
171193

172-
### Systems
194+
## Systems
195+
196+
### Introduction
173197

174-
**Introduction:** The [Systems](#systems) are responsible for controlling all of your Entity's [Components](#components) and are the closest you'll get of what you're used to when working with MonoBehaviours. The entire life cycles of your Entities are managed in here.
198+
The [Systems](#systems) are responsible for controlling all of your Entity's [Components](#components) and are the closest you'll get of what you're used to when working with MonoBehaviours. The entire life cycles of your Entities are managed in here.
175199

176200
```csharp
177201
public class MovementSystem : System<MovementSystem, MovementComponent> { }
178202
```
179203

180-
**Virtual On Initialize:** The [System](#systems) consists of an OnInitialize virtual method. This method can be overwritten and will be invoked during the very start of your Application. During this cycle properties with the Injected and Asset attribute are being assigned. This cycle can be used to create instances or pre-set properties. Keep in mind references to other [System](#systems) and [Services](#services) are yet to be assigned and are not available at this point.
204+
### Virtual On Initialize
205+
206+
The [System](#systems) consists of an OnInitialize virtual method. This method can be overwritten and will be invoked during the very start of your Application. During this cycle properties with the Injected and Asset attribute are being assigned. This cycle can be used to create instances or pre-set properties. Keep in mind references to other [System](#systems) and [Services](#services) are yet to be assigned and are not available at this point.
181207

182208
```csharp
183209
public class MovementSystem : System<MovementSystem, MovementComponent> {
184210
public override void OnInitialize () { }
185211
}
186212
```
187213

188-
**Virtual On Initialized:** The [System](#systems) consists of an OnInitialized virtual method. This method can be overwritten and will be invoked when all [System](#systems) and [Services](#services) did initialize, and all the properties with the Injected and Asset attributes are assigned.
214+
### Virtual On Initialized
215+
216+
The [System](#systems) consists of an OnInitialized virtual method. This method can be overwritten and will be invoked when all [System](#systems) and [Services](#services) did initialize, and all the properties with the Injected and Asset attributes are assigned.
189217

190218
```csharp
191219
public class MovementSystem : System<MovementSystem, MovementComponent> {
192220
public override void OnInitialized () { }
193221
}
194222
```
195223

196-
**Virtual On Enabled:** The [System](#systems) consists of an OnEnabled virtual method. This method can be overwritten and will be invoked when all [System](#systems) and [Services](#services) are initialized or when the [System](#systems) is enabled after being disabled.
224+
### Virtual On Enabled
225+
226+
The [System](#systems) consists of an OnEnabled virtual method. This method can be overwritten and will be invoked when all [System](#systems) and [Services](#services) are initialized or when the [System](#systems) is enabled after being disabled.
197227

198228
```csharp
199229
public class MovementSystem : System<MovementSystem, MovementComponent> {
@@ -203,7 +233,9 @@ public class MovementSystem : System<MovementSystem, MovementComponent> {
203233

204234
<!-- TODO OnEntityInitialzed, OnEntityEnabled, OnPhysics, ShouldUpdate, OnUpdate, OnRender, OnDrawGui, OnDrawGizmos, OnDisabled, OnEntityDisabled, OnEntityWillDestroy, OnWillDestroy -->
205235

206-
**Checking wether an Entity is enabled:** To check whether Entities are enable or disabled, the [Component](#components) consists of a property isEnabled. Getting the value will return a boolean informing if the Entity is enabled or not.
236+
### Checking wether an Entity is enabled
237+
238+
To check whether Entities are enable or disabled, the [Component](#components) consists of a property isEnabled. Getting the value will return a boolean informing if the Entity is enabled or not.
207239

208240
```csharp
209241
public class MovementSystem : System<MovementSystem, MovementComponent> {
@@ -213,7 +245,9 @@ public class MovementSystem : System<MovementSystem, MovementComponent> {
213245
}
214246
```
215247

216-
**Dependency Injection:** The [System](#systems) allows the use of the Injected attribute on properties to automatically assign the values of referenced [Systems](#Systems), [Services](#Services) and [Controllers](#controllers), making all public methods and properties accessible. These properties are assigned during the OnInitialize cycle and are available for use at the OnInitialized cycle.
248+
### Dependency Injection
249+
250+
The [System](#systems) allows the use of the Injected attribute on properties to automatically assign the values of referenced [Systems](#Systems), [Services](#Services) and [Controllers](#controllers), making all public methods and properties accessible. These properties are assigned during the OnInitialize cycle and are available for use at the OnInitialized cycle.
217251

218252
```csharp
219253
public class MovementSystem : System<MovementSystem, MovementComponent> {
@@ -223,7 +257,9 @@ public class MovementSystem : System<MovementSystem, MovementComponent> {
223257
}
224258
```
225259

226-
**Assets:** The [System](#system) allows the use of the Asset attribute on properties to automatically assign the values of referenced Assets. Assets can be assigned on the [Controller](#controllers) instance in your Scene. When assigning using the empty contructor, the property's name will be used for searching the Asset, to find an Asset by it's name, use the string overload. All types of UnityEngine's Object can be used in these fields. These properties are assigned during the OnInitialize cycle and are available for use at the OnInitialized cycle. When an asset is not found, an error is thrown.
260+
### Assets
261+
262+
The [System](#system) allows the use of the Asset attribute on properties to automatically assign the values of referenced Assets. Assets can be assigned on the [Controller](#controllers) instance in your Scene. When assigning using the empty contructor, the property's name will be used for searching the Asset, to find an Asset by it's name, use the string overload. All types of UnityEngine's Object can be used in these fields. These properties are assigned during the OnInitialize cycle and are available for use at the OnInitialized cycle. When an asset is not found, an error is thrown.
227263

228264
```csharp
229265
public class MovementSystem : System<MovementSystem, MovementComponent> {
@@ -234,17 +270,19 @@ public class MovementSystem : System<MovementSystem, MovementComponent> {
234270

235271
_The systems section of the documentation is in process!_
236272

237-
### Services
273+
## Services
238274

239-
**Introduction:**
275+
### Introduction
240276

241277
```csharp
242278
public class AudioService : Service<AudioService> { }
243279
```
244280

245281
<!-- TODO OnInitialize, OnInitialized, OnDrawGui, OnDrawGizmos, OnWillDestroy -->
246282

247-
**Dependency Injection:** The [Service](#services) allows the use of the Injected attribute on properties to automatically assign the values of referenced [Systems](#Systems), [Services](#Services) and [Controllers](#controllers), making all public methods and properties accessible. These properties are assigned during the OnInitialize cycle and are available for use at the OnInitialized cycle.
283+
### Dependency Injection
284+
285+
The [Service](#services) allows the use of the Injected attribute on properties to automatically assign the values of referenced [Systems](#Systems), [Services](#Services) and [Controllers](#controllers), making all public methods and properties accessible. These properties are assigned during the OnInitialize cycle and are available for use at the OnInitialized cycle.
248286

249287
```csharp
250288
public class AudioService : Service<AudioService> {
@@ -254,7 +292,9 @@ public class AudioService : Service<AudioService> {
254292
}
255293
```
256294

257-
**Assets:** The [Service](#services) allows the use of the Asset attribute on properties to automatically assign the values of referenced Assets. Assets can be assigned on the [Controller](#controllers) instance in your Scene. When assigning using the empty contructor, the property's name will be used for searching the Asset, to find an Asset by it's name, use the string overload. All types of UnityEngine's Object can be used in these fields. These properties are assigned during the OnInitialize cycle and are available for use at the OnInitialized cycle. When an asset is not found, an error is thrown.
295+
### Assets
296+
297+
The [Service](#services) allows the use of the Asset attribute on properties to automatically assign the values of referenced Assets. Assets can be assigned on the [Controller](#controllers) instance in your Scene. When assigning using the empty contructor, the property's name will be used for searching the Asset, to find an Asset by it's name, use the string overload. All types of UnityEngine's Object can be used in these fields. These properties are assigned during the OnInitialize cycle and are available for use at the OnInitialized cycle. When an asset is not found, an error is thrown.
258298

259299
```csharp
260300
public class AudioService : Service<AudioService> {

0 commit comments

Comments
 (0)