Editor Tool for ECS data

I need to setup waypoint graphs where edges connect to nodes and nodes reference edges etc…they are not really game objects, they are just data that i want to be able to see in the scene.

Is there a way to create a editor tool that directly creates these entities since i already have systems in place to deal with the logic of creating connections and deleting them etc. I want to use those systems in editor so i can create my scene with a level editor tool…

I can’t seem to find much info out there on this. If i have to use GameObjects then bake it as the only option that seems incredibly tedious as i have to write connection logic and delete logic twice, one for live and one for an editor…

I was researching about this today. What I found is you can get all worlds using World.All. The world in the editor is named “Editor World”. Once you have this world, you can do whatever you want like adding/retrieving systems. You can then query entities normally in these systems. I haven’t looked if system update works but I could definitely query entities and add components on them. Not sure if these would be saved but that’s not yet part of my use case.

I’m doing pretty much that, but it comes with the downside that you will need to handle serialization and loading of your data yourself, since the entities you create will not be saved in the subscene.

My setup looks pretty much like this:

  • My custom EditorWindow handles all the code for modifying the entity data. It mostly works in the viewport, so I’m subscribing to SceneView.duringSceneGui to handle all the viewport interactions. The EditorWindow class instance holds all the serialized data in standard managed Lists, Dictionaries, etc.
  • Whenever I need to update the entity data from my custom editor, I call a function in which I set the entity data. You can just get the EntityManager with EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
  • In my case, I actually just set a singleton entity with a reference to my editor window. I then have an editor-only system which takes the managed Lists, etc., and converts them to the actual entity data. But you could also just create your needed entities directly with the EntityManager inside the EditorWindow code.
  • In my editor code, I serialize my data to json files and have a separate system at runtime to convert the json data back to entities.

This can be implemented in many other ways. The takeaway is you can just get the EntityManager to create any custom entity data you need, as long as you have a way to also load the data at runtime.


In most cases just using baking is more straightforward since you don’t need to deal with serialization yourself. But in my case I needed the json data anyway and instant live feedback was very important so I didn’t want to go through the baking pipeline.

1 Like