Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Pure DOTS Map Editor in "EditorTime"?

Discussion in 'Entity Component System' started by fajerbujt, Nov 9, 2020.

  1. fajerbujt

    fajerbujt

    Joined:
    Feb 29, 2020
    Posts:
    14
    I'm trying to create a MapEditor for my Grid based World but having some troubles.

    I have an Authoring component;
    WorldMapAuthoring
    that has a
    GameObjectConversionSystem
    that creates a WorldMap entity and a WorldCell entity for every cell in the grid. So a 2x2 grid would create entities like this:
    upload_2020-11-9_23-48-43.png
    Which works great & the entities are loaded into the EditorWorld.

    I then have other Editor systems that let me add/modify components on the cells, set cell types, elevation etc. that changes the map.

    However when I run the project the changes that were made on my WorldMap entity & it's cells in "editor time" are not persistent & the conversion code will run again, recreating all the cells thus removing all the modification I did.

    Is there a way to save my entities (The entities are already created so running the conversion code on every "Enter playmode" seems redudant?). Or maybe access the corresponding Entities in the EditorWorld & copying them? Maybe there is another Conversion/authoring flow or technique I should use thats better suited for what I'm trying to do?

    What I want is that the Editor tools generates the Entities in "edit time" instead of handling GameObjects that converts to entities only in runtime.

    Would appreciate any help/guidlines!
     

    Attached Files:

    Last edited: Nov 10, 2020
  2. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    909
    Are you doing this in the editor? Is the subscene closed? If it's open it'll go through the default conversion process.
    When it's closed it won't.
     
  3. fajerbujt

    fajerbujt

    Joined:
    Feb 29, 2020
    Posts:
    14
    I see, closing the SubScene does exactly what I want/assumed subscenes worked, thanks!!

    Do you know if there is a way to have a SubScene always be open in the Editor & close/save it right before enter playmode?
     
  4. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    909
    Watch the editor world in Dots Editor -> Entities to see how it behaves. It can also help you debug when things go wrong with the cache.

    I have only prefabs in my subscene so I can keep it closed and still have the entities loaded. When I change a prefab from the project folder, the subscene and the entity cache is automatically updated. That way I don't have to do anything. :)
     
    Sarkahn likes this.