Search Unity

Rebuild Entity Cache gone? How to rebuild the entity Cache on SubScenes?

Discussion in 'Entity Component System' started by BerndEissing, Feb 13, 2020.

  1. BerndEissing

    BerndEissing

    Joined:
    May 14, 2018
    Posts:
    3
    Hey I recently started programming in Unity and wanted to use ECS right from the beginning. I followed this guide:
    on how to set up a rotating cube.

    Versions:
    Unity: 2020.1.0a22.2822
    Burst: 1.2.2
    Entities: 0.5.1
    Hybrid Renderer: 0.3.3
    Jobs: 0.2.4
    Mathematics: 1.1.0
    Unity Physics: 0.2.5

    At 20:21 he tries to play the game and the cube doesn't rotate and as a solution he "rebuilds the entity cache"
    as shown in this picture:

    Rebuild_Entity_Cache.png

    But this Option is missing in my Inspector. So my first questions is how do I rebuild the entity cache?

    My other problem, or bug, is that any changes made to the attached script on the Entity in the SubScene are not showing up. Take this picture for example:

    Unity_View.png

    I have a Cube inside my sub scene "Cube". If I understand correctly this Cube is an Entity itself. The Script Rotate Autoring could also be called Rotate Component to represent the "Component" in "ECS" I think.

    So selecting the Cube while the "Cube" sub scene is in "Edit" mode shows the following data in the Inspector:

    Cube_Selected.png

    Hightlighted in red is the ComponentData that I added manually via the Rotate Authoring script. Here is the script:

    Rotate_Component.png

    When I make changes to this Script and "close" the "Cube" sub scene. The changes are not applied to the entity. Take the following change for example:

    Rotate_Component_new_Rotation.png


    If I go back to Unity, "close" the "Cube" sub scene and selecy my Entity it is missing the RotationEulerYXZ in the Inspector. And if I create a System now that wants to access my new value it wont find it in my Entity.

    I have a hunch that the Entity Cache is making me problems but I have yet to find a way to update it. Sorry for the long post. Any help would be apreciated!
     
  2. ssilbery

    ssilbery

    Joined:
    Feb 15, 2020
    Posts:
    1
    I have the exact same problem.

    Edit - I discovered the way to do it is by deleting the "SceneDependencyCache" folder in project tab. I guess this forces a rebuild of the Cache.
     
    Last edited: Mar 7, 2020
    lclemens likes this.
  3. JonasDeMaeseneer

    JonasDeMaeseneer

    Joined:
    Oct 4, 2018
    Posts:
    4
    When you change code that modifies conversion, use/modify the ConverterVersionAttribute. (Place that attribute above a ConversionSystem or IConvertGameObjectToEntity)

    Otherwise the caches should get automatically rebuilt based on unity's dependency system.

    For closed subscenes it's worth noting that I've had many instances where automatic cache rebuilding did not pick up a change in the scene. Main issues were: not picking up a prefab modification, scriptable object modification, empty authoring component.

    When that happens i have to slightly change the transform of the object & press save.
     
  4. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    761
    The thing is... I DID change the the version attribute! I had this:

    Code (CSharp):
    1. [ConverterVersion("SpawnerConverter", 2)]
    2. public class SpawnerConverter : MonoBehaviour, IConvertGameObjectToEntity
    3. { ... }
    I changed the 1 to a 2 and then to a 3 for good measure. I tried loading/unloading, closing/opening, and reimporting. I also tried the menu item DOTS/Clear Entities Cache(s). And doing all that did jack and squat.

    The ONLY thing that actually worked was doing what ssilbery said... deleting the "Assets/SceneDependencyCache" folder. I'm using 2020.2.0. So thank you @ssilbery , I wish I had read your post 2 hours ago!
     
    florianhanke likes this.