Search Unity

Resolved SubsystemRegistration

Discussion in 'Scripting Dev Blitz Day 2023 - Q&A' started by Baste, Feb 23, 2023.

  1. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    The different RuntimeInitializeOnLoadTypes are fairly easy to understand - except the SubsystemRegistration.

    When exactly does our code get run relative to other things when we use

    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
    ? How does this differ between editor and runtime?
     
  2. SF_FrankvHoof

    SF_FrankvHoof

    Joined:
    Apr 1, 2022
    Posts:
    780
  3. Maria_Angelova

    Maria_Angelova

    Unity Technologies

    Joined:
    Mar 3, 2020
    Posts:
    29
    I agree documentation here is lacking. I don't actually see any big difference between editor and play mode for this call back. But generally speaking this is the order of events: DoneInitializingEngineGraphics -> SubsystemRegistration -> AfterAssembliesLoaded -> BeforeSplashScreen -> BeforeSceneLoad -> AfterSceneLoad -> Awake
     
  4. SF_FrankvHoof

    SF_FrankvHoof

    Joined:
    Apr 1, 2022
    Posts:
    780
    Could be me, but this seems odd..
    Wouldn't the assemblies need to be loaded for SubsystemRegistration to start? Since the Subsystems are (generally) part of those assemblies?
     
  5. Maria_Angelova

    Maria_Angelova

    Unity Technologies

    Joined:
    Mar 3, 2020
    Posts:
    29
    At the SubsystemRegistration time, all assemblies are loaded in the sense that all code and systems is present in the domain and can be executed. SubsystemRegistration event is an opportunity for systems to correctly initialize themselves and hook up to relevant other systems as part of the assembly loading process.
     
    SF_FrankvHoof likes this.