Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How do I cache Entities in Editor

Discussion in 'Entity Component System' started by RoughSpaghetti3211, Jun 30, 2019.

  1. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,697
    Wondering if anyone can help me, Im trying to create and cache entities from the Editor before runtime. Ive had success cacheing gameObjects using subScenes but how do I handed caching with no Game Objects?
    Catch is I need this to run this after my GameObjectConversionSystem since I need that data to create and cache my entities.

    Thanks in advance for the help
     
  2. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,697
    Anyone know where the code lives for how subscenes are doing this
     
  3. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,753
    You can create groups of entities in the editor and serialize them to disk and deserialize them at runtime with.

    SerializeUtilityHybrid.Serialize();
    SerializeUtilityHybrid.Deserialize();

    If you want to convert game objects to entities then cache them you can use

    GameObjectConversionUtility.GameObjectToConvertedEntity

    which is what converttoentity does
     
  4. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,697
    What if I have a NativeArray<Entity> and I want to create and cache them. Exactly what the SubScene are doing for game object
     
  5. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,753
    Look at the source and find out yourself?
     
    RoughSpaghetti3211 likes this.
  6. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,697
    Perfect digging through it now just wanted to makes sure the API supposed my use case. Appreciate the help , I apologize for my previous post it was a bit lazy.