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 [Best Practice] ECS & Settings management

Discussion in 'Entity Component System' started by Touhma_Slater, Sep 22, 2023.

  1. Touhma_Slater

    Touhma_Slater

    Joined:
    Nov 19, 2014
    Posts:
    20
    Here is my Context :
    I'm working on a project , a factory builder POC since a while and a lot of stuff happen in the code. So I try to organise the project in a nice & scalable way.

    Problematics :
    What are the practices arounds configs & settings for a project revolving around ECS ?
    I need to have references to Mesh, Materials , Prefabs & a lot of blittable datas.( cf screenshots )
    Currently i'm doing like so :

    Subscenes & putting the settings in IComponentsData that the systems then query at startup to feed the differents processes. ( shared statics creation / update if needed for bursted statics functions ) I'm having custom baker to tag the baked entities In the system when I need the settings : ( cf screenshot )

    Entity conveyorSettingEntity SystemAPI.ManagedAPI.GetSingletonEntity<ConveyorPrefabSettingsComponentData>(); ConveyorPrefabSettingsComponentData conveyorSettings = SystemAPI.ManagedAPI.GetComponent<ConveyorPrefabSettingsComponentData>(conveyorSettingEntity);

    I'm doing something like this. Is it the right way of doing that ?
    Because it seems like i'm writing a LOT of boilerplate code for stuff that i would normaly do with scriptable objects and simply look from the reference what I need in the data.
    I feel Like i'm doing something wrong but it's hard to find any real life example of that open sourced on github.

    Any help / Opinions ?

    Thanks ! (modifié)
     

    Attached Files:

  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,574
    If you talking about config, for global data, you can either create singleton entities, with relevant settings, or having static structs, with relevant properties, which can be accessed globally. You can use constants properties for example.

    Singleton entities are easier for debugging in Entities debugger.
     
  3. Touhma_Slater

    Touhma_Slater

    Joined:
    Nov 19, 2014
    Posts:
    20
    Hummmm so there is no problems at having singleton entities for it then.

    Noice. It still seems like a lot of boilerplate for a simple feature ...

    But alright. thanks ;)