New Code Generator available in the Asset Store
See original GitHub issueNew Code Generator available in the Unity Asset Store
Hi guys, I’ve just got an Email from Unity. The new Entitas version is available in the Unity Asset Store including the first public beta of the new Code Generator! Here’s a quick guide to get started. Better docs + Video Tutorials are coming very soon. This version was uploaded with Unity 2017.2, older version will be available soon!
First Steps
- Open Unity
- Ceate a new project
- Create a new folder called Libraries (or update the default paths in Entitas.properties later)
- Download Entitas from the Asset Store
- Move the downloaded package into the libraries folder you just created
- Create a new Component : IComponent
using Entitas;
public class IdComponent : IComponent {
public string value;
}
- In Unity select the menu item Assets -> Open C# project
- Open the the Entitas Preferences and enable all Plugins
- Check the searchPaths in Entitas.properties if you’re on windows (the default ones are for Mac)
- Press the green generate Button
- You’ll find the generated code in Sources/Generated
Using the new code generator
- Move Libraries/Entitas/CodeGenerator.zip to your project root (one folder above the Assets folder)
- Unzip it (on Windows make sure to right click -> Properties -> Unlock to safely unzip)
- Open Entitas.properties (located in the project root folder)
- Add
CodeGenerator/Plugins/Entitas.Roslynto the searchPaths - Add
Entitas.Roslyn.CodeGeneration.Pluginsto the plugins - Find the DataProvider called
Entitas.CodeGeneration.Plugins.ComponentDataProviderand add.RoslynafterEntitas->Entitas.Roslyn.CodeGeneration.Plugins.ComponentDataProvider - Do the same for
Entitas.CodeGeneration.Plugins.EntityIndexDataProvider->Entitas.Roslyn.CodeGeneration.Plugins.EntityIndexDataProvider - We just plugged in the Roslyn Code Generator Plugin and are using the DataProviders
- Open the terminal and
cdinto your project root - run
CodeGenerator/entitas.exe doctor - on a mac run
mono CodeGenerator/entitas.exe doctor - You should see
No problems detected. Happy coding :) - If not, check your searchPaths, especially if the point to the correct Unity location
- run
CodeGenerator/entitas.exe gen -a(prepend mono when on a mac) - It will generate using the new code generator.
-awill ask youAgain ? (y / n) - Press
yif you want to generate again (e.g. after adding more components) - Press
nto terminate the programm
What you should try
The new code generator will be able to generate the latest changes in your code even when there compile erros. Try it yourself!
using Entitas;
public class IdComponent : IComponent {
public string value;
}
After generating change the field type from string to int which will result in errors. Switch to the terminal and hit y to generate again. Open the generated file GameIdComponent to verify and see for yourself.
The errors are all gone. You can switch the type back to string and intentionally add more compiler errors by smashing the keys on your keyboard
using Entitas;
// more compiler errors
fdsf dh aksjhdgk sh
fsdf
sdfkjhgaskfjhg
public class IdComponent : IComponent {
public string value;
}
Switch to the terminal and hit y to generate again. The new code generator will be able to generate anyway.
Add more components, rename them, delete them, add and remove fields, it should all work seamlessly!
Happy coding 😃
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:30 (13 by maintainers)

Top Related StackOverflow Question
Entitas 0.43.0 available to address most of the initial feedback! Asset Store version should be available in 2-4 days
Running Generate from inside of Unity freezes the Editor.