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 Do you know of a ScriptableObject framework that can use components?

Discussion in 'Entity Component System' started by davenirline, Jun 5, 2023.

  1. davenirline

    davenirline

    Joined:
    Jul 7, 2010
    Posts:
    943
    How I wish ScriptableObjects support components. I would like to make ScriptableObjects prepare an entity like each component support an interface where I can then pass it an EntityManager or EntityCommandBuffer.
     
  2. philsa-unity

    philsa-unity

    Unity Technologies

    Joined:
    Aug 23, 2022
    Posts:
    113
    I'm not sure if this is what you mean, but one way to deal with ScriptableObjects in ECS is to convert their contents to a blobasset:
    • Make your ScriptableObject just contain a [System.Serializable] struct, and that struct is what contains the actual unmanaged data.
    • Create authorings that have a field where you can assign that ScriptableObject.
    • During baking, take the "data" struct of the ScriptableObject and put it into a blob asset. Store the BlobAssetReference in a component on the entity.
    • Don't forget to make the baker depend on that scriptable object, so baking is re-triggered when the SO changes (in baker: "DependsOn(authoring.MyScriptableObject);").
     
    Last edited: Jun 5, 2023
    Mortichar, MostHated, mgi388 and 2 others like this.