Skip to content

Unity integration

Simon Schmid edited this page Jan 17, 2016 · 19 revisions

Entitas.Unity.CodeGenerator

Entitas.Unity.CodeGenerator extends Unity with a menu item that generates code with a single click.

Entitas.Unity.CodeGenerator

It also plugs into the Entitas preferences, where you can specify the path to the folder, where the generated files should be saved. You can specify multiple pools and the corresponding Pools and PoolAttributes will be generated for you.

Entitas.Unity.CodeGenerator

Entitas.Unity.VisualDebugging

Visual Debugging enables you to actually see and inspect all of your entities in the Unity Editor. Use the generated Pools.pool or add PoolObserver to your pool. That's it!

var pool = Pools.pool;
var pool = new Pool(ComponentIds.TotalComponents, 0, new PoolMetaData("Pool", ComponentIds.componentNames));
#if (!ENTITAS_DISABLE_VISUAL_DEBUGGING && UNITY_EDITOR)
var poolObserver = new PoolObserver(pool, ComponentIds.componentTypes);
Object.DontDestroyOnLoad(poolObserver.entitiesContainer);
#endif

Once you use the PoolObserver the pool and their entities will automatically show up in the hierarchy.

Entitas.Unity.VisualDebugging-Preferences-Hierarchy

Entitas.Unity.VisualDebugging-DebugPool

Although entities are no GameObjects and components are no MonoBehaviours you can inspect them as if they were. All components of the selected entity are listed and all their fields are exposed. You can manipulate or remove components at runtime and even destroy the entity. All the default Unity drawers are supported and you can easily create your own ITypeDrawer to draw custom objects. Take a look at these implementations

Entitas.Unity.VisualDebugging-Entity

When you select multiple entities, you can manually destroy some of them or batch destroy all of them.

Entitas.Unity.VisualDebugging-Entity-MultiTarget

Entitas.Unity.VisualDebugging also plugs into the Entitas preferences, where you can specify the folders where you want to save the generated IDefaultInstanceCreator and ITypeDrawer implementations.

When using DebugSystems instead of Systems you can easily monitor all your systems and identify slow systems.

Entitas.Unity.VisualDebugging-DebugSystems

Give it a try and checkout the example projects

Clone this wiki locally