-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Generate your first component
FNGgames edited this page Mar 17, 2017
·
13 revisions
Let's create our first custom component and let the Code Generator do its magic!
Open the Entitas preferences and set the Generated Folder
path where the Code Generator should save files.
Create a new class and implement IComponent
using Entitas;
public class PositionComponent : IComponent {
public float x;
public float y;
public float z;
}
Select Entitas/Generate
Create a GameController script
public class GameController : Monobehaivour {
void Start() {
var contexts = Contexts.sharedInstance;
_systems = createSystems(contexts);
_systems.Initialize();
}
void Update() {
_systems.Execute();
_systems.Cleanup();
}
void OnDestroy() {
_systems.TearDown();
}
Systems createSystems(Contexts contexts) {
return new Feature("Systems")
// here is where you'd add your created systems
.Add(new MySystem(contexts))
.Add(new MyOtherSystem(contexts));
}
}
For Example Systems see [Systems] (https://github.com/sschmid/Entitas-CSharp/wiki/Systems).
For more code examples see Code Generator
Guides: Introduction - Installation - Upgrading - FAQ - Cookbook - Contributing
Need Help? Ask a question on Discord or create an issue.
- The Basics
- Concepts
- Architecture / Patterns