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
  2. Enter the 2020.2 Beta Sweepstakes for a chance to win an Oculus Quest 2.
    Dismiss Notice

Editor: Domain reload and / or scene reload

Discussion in '2019.3 Beta' started by Lars-Steenhoff, May 17, 2019.

  1. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,804
    • Editor: Domain reload and / or scene reload could be disabled when entering play mode to allow faster iteration times in the editor.

      This is amazing, instant play without any lag, thanks for including this!

      First test are really promising, there were sometimes missing references, but that was a problem with a script that I purchased. Enabling domain reload fixed that for now, but I will investigate it more.
     
  2. HonorableDaniel

    HonorableDaniel

    Joined:
    Feb 28, 2007
    Posts:
    2,970
    Is this enabled by default? If not, how do you turn it on? It sounds amazing!

    Edit: Figured it out. Edit->Project Settings->Editor->Enter Play Mode Settings.

    So far it's feeling like magic!

    Does anyone know what the drawbacks are of it? Is there a way to manually trigger domain reload and is that even necessary?
     
    Last edited: May 18, 2019
    Lars-Steenhoff likes this.
  3. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,370
    The main drawback is that none of the state stored in the domain is reset. So for example, if you have static variables in your classes and you have [ExecuteInEditMode] scripts or custom Editor scripts which cause those static variables to be set, then turning off the domain reload means the static variables will not be nulled/zeroed when entering play mode anymore.
     
  4. HonorableDaniel

    HonorableDaniel

    Joined:
    Feb 28, 2007
    Posts:
    2,970
    That makes me want to write a script that resets all static variables on entering play mode.
     
  5. julian-moschuering

    julian-moschuering

    Joined:
    Apr 15, 2014
    Posts:
    423
    Get rid of your static variables.
     
  6. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,370
    Note that re-initializing all the static variables is a big part of where domain reload time actually goes. If we just did a blanket reset of all static state, then we'd also need to rerun all the [InitializeOnLoad] methods etc, and almost all the cost savings would be gone (like we'd be skipping re-JIT of the code but that'd be all). If you want to create your own tools to reset static state, you will definitely want to pick and choose what you apply that to.
     
  7. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,804
    Would it be an idea to make one extra option ?
    Domain reload with only re-JIT

    I don't know what impact re-JIT has on a large project with many scripts?

    I say this because I have some projects with many scripts that I purchased on the asset store and I can't remove all the static variables from those assets because I simply would not know how.

    This way there is perhaps still some time saving while not trowing up errors for static variables.
    Might be interesting to explore
     
  8. julian-moschuering

    julian-moschuering

    Joined:
    Apr 15, 2014
    Posts:
    423
    Small Feedback: We saved around 17 seconds. Went from 23 seconds of intial loading screen to 6 seconds. Full launch halfed due to this. Thanks!!!
     
    sean244, 5argon, Seb-1814 and 5 others like this.
  9. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,370
    I believe the team looked into it, and the impact of JIT itself is negligible.
     
  10. Pyromuffin

    Pyromuffin

    Joined:
    Aug 5, 2012
    Posts:
    80
    This is very cool!
    There seems to be a bug with shuriken though. Particle systems don't start playing when switching to play mode unless you start them in the editor by hitting the "play" button in the "particle effect" scene gui.
     
  11. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,510
    Just when I thought I could settle down with 2018.3 new prefabs, 2019.1 has timeline signals I need to make my UI.
    Then when I think I could settle down with 2019.1, then this killer feature came.

    Mine went from 11s to 0.5s. This is unreal. Thanks a lot for this feature!
    I might as well print out the release note and frame it.
     
  12. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    538
    no this is Unity
    :p
     
    andreiagmu and Gua like this.
  13. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,510
    Thank you
     
    andreiagmu likes this.
  14. alexeyzakharov

    alexeyzakharov

    Unity Technologies

    Joined:
    Jul 2, 2014
    Posts:
    397
    Thank you for testing the feature!
    We are working on docs to explain all drawbacks and how to avoid those (statics not being reset, [NonSerialized] fields being kept, etc.)

    Please file a bug for this - I suspect the scene reset path doesn't reinitialize Particle system properly.
     
    richardkettlewell likes this.
  15. dzamani

    dzamani

    Joined:
    Feb 25, 2014
    Posts:
    116
    Hi, I have a few questions:
    - is there a reload when you stop in editor ?
    - is there any impact on scriptable objects or other things you would live edit on play and then press stop (same question but before pressing play)
     
  16. alexeyzakharov

    alexeyzakharov

    Unity Technologies

    Joined:
    Jul 2, 2014
    Posts:
    397
    No. There is no domain reload when you exit playmode.
    Domain reload only happens when scripts are recompiled and has to be integrated, and (by default) when entering Playmode.

    The feature doesn't change any exit playmode behavior. So there is no impact on things you edit and press stop.
    When you press play with domain reload disabled the data of scriptable objects remains. The major difference between enterplaymode without domain reload and with domain reload is - 1) static fields are not reset and static type initializers are not called, 2) fields marked with [NonSerialized] keep their values.
    The editing workflow is unchanged.
     
  17. mountblanc

    mountblanc

    Joined:
    Sep 24, 2015
    Posts:
    75
    I starting a new project from scratch using Unity 2019.3.0a5 (due to this feature) for a week now (in my limited spare time) And i have to say I never want to go back to older versions.
    Even do some Packages like 2D Animation and Vector Graphics are not working (yet)
    The only thing i want back is the time i wasted before this feature existed! ;-)
    I suspect do due to the static 'limitation's that many current editor related assets will break. (or at least act strange at times)
    Luckily I only use one asset so far and that gives me no problems.

    The play button turned into a Harry Potter button. Touching it feels like magic!
     
  18. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    691
    I'm really happy but at the same time really mad.
    They should've done it a long time ago and we would have saved countless hours.
    It's too bad that they just realize and they better be sorry but at the same time, I'm really happy we can have a better future. It a funny feeling.

    It's better late than never but it will take a while before we all adopt it. If one asset you are using causing a problem, you cannot use Instant Play, and it will be very disappointing.
    Therefore, I wanted to have them to make the Instant Play available as soon as possible (for 2019.2 ??) so that Asset developers have time to make it compatible but then, it looks like we will have to wait until 2019.3 releases (Most of the asset developers will not touch beta product after being burned by beta so many times)
    Unity has broken so many promises delivering stuff late and why they can't they deliver something earlier than scheduled just for once? It's an optional feature and it won't hurt anyone.

    Well, if they can't deliver it earlier, the only thing I ask is to make sure it's easy/rock-solid to integrate once 2019.3 release so that asset developers will easily optin and as fast as possible. Since we know it's possible to support Instant Play, I cannot wait any longer. Waiting for 2019.3 and beyond is just too painful.

    Thanks.

    ps. I wanted to test this on my project but the stupid missing UI assembly is stopping me from it. Don't they do any sort of compatibility testings before they do something? Sigh...
     
    alexeyzakharov likes this.
  19. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    212
    @alexeyzakharov for a large AAA project that takes ~10 to 20 minutes to first enter play mode (reproducible on multiple employee machines), is there a general % of time reduction expected?

    and are there other editor performance improvements Unity is working on?
     
    fherbst and alexeyzakharov like this.
  20. alexeyzakharov

    alexeyzakharov

    Unity Technologies

    Joined:
    Jul 2, 2014
    Posts:
    397
    Hi @XRA!
    Is it possible to take a profiler capture (ProfilerEditor + Hierarchy View)?
    If you say first enter play mode, building sprite atlases comes to my mind. Do you use a lot of those?

    There is a work going on in multiple areas, but I'm not sure if that covers your use case. 10 to 20 minutes to enter playmode is for sure too much. If we could pinpoint it better, we could understand how to fix/avoid such a long hang.
     
  21. Ziplock9000

    Ziplock9000

    Joined:
    Jan 26, 2016
    Posts:
    194
    It would be good if there was a button near the play mode settings you could press that would point out which code is likely to have these drawbacks. It may take time for Unity to develop, but would save on a huge amount of tech support and devs pulling their hair out.
     
    Lars-Steenhoff likes this.
  22. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    342
    You're doing something wrong if entering play mode takes over 10mins. Try to have as empty scenes as possible and load your stuff in code, for exmaple using async loading.
     
  23. eneko-unity

    eneko-unity

    Unity Technologies

    Joined:
    Jan 23, 2018
    Posts:
    1
    Hi,

    You could use the new APIs

    https://docs.unity3d.com/2019.3/Doc...ilationPipeline.RequestScriptCompilation.html (Recompiles the scripts and reload them)

    https://docs.unity3d.com/2019.3/Documentation/ScriptReference/EditorUtility.RequestScriptReload.html (Reload the scripts without recompiling)

    Cheers,

    Eneko
     
    Last edited: Aug 29, 2019
    Johannski and SugoiDev like this.
  24. OmegaNemesis28

    OmegaNemesis28

    Joined:
    Dec 1, 2012
    Posts:
    95
    Sorry for resurrecting this, but would it make sense to invoke a domain reload when you *exit* playmode rather than on enter perhaps? Using the API above. I think that's what a previous comment was alluding to.
     
  25. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    228
    I think the documentation is missing some vital info. One major difference with Domain Reload Disabled is that ScriptableObjects don't get reloaded on entering Play. This means that any runtime data that was expected to be re-created in OnEnable will remain and become outdated. I think this needs to be mentioned in the docs.

    On this note, does anyone know the most efficient way to re-load ScriptableObjects manually in the editor?
     
    Last edited: Aug 3, 2020
    Lars-Steenhoff likes this.
  26. Boltman

    Boltman

    Joined:
    Feb 12, 2015
    Posts:
    7
    This is definitely true and made me a little crazy trying to find what was happening.
    The docs don't mention it at all and they really should.
    I was lulled into the false sense of security that domain reloading only affected static stuff.
    But for scriptable objects, even NON-serialized, NON-static fields remain with their old values.
    Don't have a good way to deal with it either, just have to manually reset them before using it anywhere.
     
    phobos2077 likes this.
unityunity