Search Unity

What's the current state of Entity prefabs and serialization?

Discussion in 'Data Oriented Technology Stack' started by illinar, Dec 20, 2018.

  1. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    563
    Thread title + Can you share your workflow when it comes to instantiating prefabs and serializing game state in ECS?

    I'm looking for a way to spawn Entities in some universal way, as you would with Prefab.Instantiate(). But when it comes to instantiating entities, it means keeping around inactive ones and filtering them in every system.

    Alternatively, I can have my custom factories but that means that each object type needs its spawning system and there are many potential problems.

    Since I usually find that I'm reinventing the wheel, I thought I'd ask first before getting into implementation and a bunch of dead ends.
     
    Last edited: Dec 20, 2018
  2. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,265
    Attach a special component called Prefab to the one you want to "keep inactive", they will not appear on any CG unless asked for like Disabled special component. But additionally when you use Instantiate the Prefab component is removed automatically.

    Serialization works on basic level, forward-backward compatibility is not good right now : https://gametorrahod.com/unity-ecs-serializing-ecs-data-252231e5b16d
     
    Jay-Pavlina likes this.
  3. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    563
    Thank you. I didn't know they had Prefab and Disabled, I'm trying to make my own prefab system based on
    ISystemStateComponentData. What I don't get is that my own component is named Prefab and there is no name conflict. What namespace is Unity's Prefab in? Edit: Ah, never mind I didn't realize they can coexist, I found the Unity.Entities.Prefab/Disabled

    Great article, that's exactly what I needed. Do you know if Unity is just reassigning chunks to other worlds without moving any memory? That would mean that it is a really fast process, and that would be great.
     
    Last edited: Dec 20, 2018
  4. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,265
    From roughly looking there is a job that just trade chunk pointer. It should be fast. In fact it is one of very few whole chunk operation we have now. Still entity remapping must be one by one
     
    illinar likes this.