Search Unity

Strange behavior accessing Active world

Discussion in 'Data Oriented Technology Stack' started by Soaryn, Apr 8, 2018.

  1. Soaryn

    Soaryn

    Joined:
    Apr 17, 2015
    Posts:
    210
    Simply using the following in a GameObject, varying results occur:
    Code (CSharp):
    1. void OnEnable() { Debug.Log(World.Active); }
    When launching the editor, the active world is displayed. "Unity.Entities.World"
    When leaving the editor on and editing code to be recompiled, the console logs 'null'

    Is this intended behavior? This currently makes a game required to be forced restarted to test new components or other small changes.

    Interestingly, the Entity Debugger also shows no active world when recompiling code whilst running.
     
    Last edited: Apr 8, 2018
  2. GabrieleUnity

    GabrieleUnity

    Unity Technologies

    Joined:
    Sep 4, 2012
    Posts:
    116
    @Soaryn the
    OnEnable
    you are referring to is attached to a script with
    ExecuteInEditMode
    ? Or when you say "leaving the editor on" you mean you are in play mode and edit and modify a script?
     
  3. Soaryn

    Soaryn

    Joined:
    Apr 17, 2015
    Posts:
    210
    Ah, by leaving the editor I mean: Starting the editor up in play mode, and going to my script in Rider whilst the editor is in play mode, editing the code, saving and clicking Unity back into focus, never stopping the game simulation. This forces a recompile of code which is intended to see changes, but it seems to wipe all world data in the process with the new entity component system.
     
  4. GabrieleUnity

    GabrieleUnity

    Unity Technologies

    Joined:
    Sep 4, 2012
    Posts:
    116
    Yeah, that's what I thought. At the moment, it is not something we are testing for, so it can be broken (and apparently it is).
    It has to do with the way we initialize and tear down the default world (check
    DefaultWorldInitialization
    ).

    You could probably overcome this behavior by having a custom world initialization path (define
    UNITY_DISABLE_AUTOMATIC_SYSTEM_BOOTSTRAP
    and provide your own logic).

    We will look towards enabling this, despite it might be quite hard to support all the possible use cases.
     
  5. Soaryn

    Soaryn

    Joined:
    Apr 17, 2015
    Posts:
    210
    Okey dokey!
    All possible use cases I don't think would be practical, but basic testing at the moment winds up being many hours of accumulated wait times for a play, test, stop, edit, start... sequence for just tweaking say an orbit object system.

    I'll play around with a custom world to see if I can make something of a "TestBenchWorld" for editing purposes.
     
    GabrieleUnity likes this.