Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Best way to initialize Singleton data

Discussion in 'Data Oriented Technology Stack' started by PublicEnumE, Aug 21, 2019.

  1. PublicEnumE


    Feb 3, 2019
    Whats the best way to go about setting up Singleton component data at the start of your game?

    I’m hesitant to write a system just to configure this data, since it will only ever need to run once. If a create a system, won’t Unity continue to consider it for updates for the entire runtime?

    Other options that leaves: ICustomBootstrap (which seems like the wrong tool for this job), and perhaps the RuntimeInitializeOnLoadAttribute.

    If you needed to setup some Singleton data at the start of your project, how would you do it?

    Thanks for any advice.
    Last edited: Aug 21, 2019
  2. recursive


    Jul 12, 2012
    I've created this framework for simplifying setup/conversion of configuration ScriptableObjects -> ECS Singletons, with support for destruction/reloading:

    I need to add test/samples and make it more compatible with ECS SubScenes, all of which are on my docket this week.

    It does work as a hybrid solution currently, as that's how I load my Game and input system configuration data.
    PublicEnumE likes this.