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. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Discussion “Recompile After Finished Playing” option is missing (or better say removed)

Discussion in 'Editor & General Support' started by pahe, Sep 13, 2022.

  1. sameng

    sameng

    Joined:
    Oct 1, 2014
    Posts:
    151
    It has been over a month since this crucial error.

    2021.3.12 LTS just launched and this is still broken. Is there any update?

    Problem:
    • When scripts get refreshed in PlayMode, every project will break.
    • Why are useful features actively being removed from LTS?
    • Disabling all Asset Refresh in PlayMode (unity's proposed solution) is ridiculous.

    What we want is simple:
    • We want to refresh shaders, materials, art in PlayMode
    • We do not want to refresh scripts in PlayMode

    There is no way to accomplish this now in the last few versions of LTS.
    Please add back "Recompile after finished playing"
     
  2. Thomas-Bousquet

    Thomas-Bousquet

    Joined:
    Dec 19, 2016
    Posts:
    19
    Ninquiet and daxiongmao like this.
  3. daxiongmao

    daxiongmao

    Joined:
    Feb 2, 2016
    Posts:
    381
    I have noticed if you just select something else then come back to unity it will refresh. Just not if you hit stop, then play again. So lots of times i end up going back to VS and back before I hit play again.

    Doing what was mentioned previously at least stops unity from just killing its self after making code changes when playing.
     
  4. Aladine

    Aladine

    Joined:
    Jul 31, 2013
    Posts:
    193
    I was about to post another thread asking for "Recompile after finished playing" .
    I hope they listen and add it back.
     
  5. moonlessformless

    moonlessformless

    Joined:
    Dec 21, 2017
    Posts:
    4
    Yes - please at least add this to known issues section so it's clear this hasn't been fully forgotten. Although just rolling back to the previous behavior would be best, as the correct workflow is absolutely to recompile on stop.

    If it's too complicated to support three options again, you could replace the absolutely useless in production "Stop Playing and Recompile" option with the much more useful "Recompile After Finished Playing".
     
  6. teutonicus

    teutonicus

    Joined:
    Jul 4, 2012
    Posts:
    62
    upload_2022-10-31_10-34-2.png
    (from 2023.1.0a16 Known Issues)
     
    Thomas-Bousquet and Kamyker like this.
  7. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    927
    Fun fact: someone reported it in May and that's when Unity found more bugs and removed it completely. https://issuetracker.unity3d.com/is...d-having-recompile-after-finished-playing-set
    I bet that this alpha version is more stable then current LTS.
     
    vulcron_unity likes this.
  8. sameng

    sameng

    Joined:
    Oct 1, 2014
    Posts:
    151
    Unfortunately Unity will fix critical bugs only in alpha versions -- puzzles the will, and makes us rather bear those bugs we have than to fly to others that we know not of? Thus... conscious does make cowards of us all. and the native hue of resolution is sicklied over with the pale cast of thought. And enterprises of great pith and moment, with this regard, their updates turn awry and lose the name of action. soft you now, the fair unity dev!

    be all my bugs remembered.
     
    Shizola likes this.
  9. Menyus777

    Menyus777

    Joined:
    Jun 11, 2017
    Posts:
    21
    Can we get an ETA on this revert on 2021 LTS?
    It would be quite helpful to decide whether to invest in making our scripts compatible with hot-reload or wait for the revert.
     
  10. stonstad

    stonstad

    Joined:
    Jan 19, 2018
    Posts:
    390
    +1 to impact and importance of keeping Recompile After Finished Playing. I don't have a single project in our portfolio that survives hot reload due to complexity. Kudos to @jdrewsen for acknowledging the urgency and communicating a planned fix.
     
  11. Suduckgames

    Suduckgames

    Joined:
    Nov 28, 2016
    Posts:
    216
    +1 , It is annoying that sometimes you forget to turn play mode off.

    Glad to hear that you are working on bring it back
     
  12. greg-harding

    greg-harding

    Joined:
    Apr 11, 2013
    Posts:
    505
    For anyone interested, 2021.3.13 does not fix this issue.
     
    goodnewsjimdotcom likes this.
  13. jdrewsen

    jdrewsen

    Unity Technologies

    Joined:
    Mar 28, 2011
    Posts:
    200
    Fix landed in our mainline. Fix now in current batches for landing in 2021 and 2022. If all goes as planned they should be in the next patch releases of 2021 and 2022. We'll let you know the specific version when it is set in stone.
     
  14. Thomas-Bousquet

    Thomas-Bousquet

    Joined:
    Dec 19, 2016
    Posts:
    19
    Thanks for the update!
    Out of curiosity, why is UUM-16168 (mentioned in the 2023 release notes) not in the public issue tracker?
    Isn't it the standard way to let user know in which version a fix is being rolled out?
     
  15. jdrewsen

    jdrewsen

    Unity Technologies

    Joined:
    Mar 28, 2011
    Posts:
    200
    The fix will be in the upcoming 2021.3.14f1 release.
     
    goodnewsjimdotcom, Menyus777 and pahe like this.
  16. jdrewsen

    jdrewsen

    Unity Technologies

    Joined:
    Mar 28, 2011
    Posts:
    200
    I don't know... will look into it.
     
    goodnewsjimdotcom likes this.
  17. jdrewsen

    jdrewsen

    Unity Technologies

    Joined:
    Mar 28, 2011
    Posts:
    200
  18. jdrewsen

    jdrewsen

    Unity Technologies

    Joined:
    Mar 28, 2011
    Posts:
    200
    The fix will also be in the upcoming 2022.2.0b16 release.
    That should be all affected releases.
     
    goodnewsjimdotcom likes this.
  19. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    927
    Are there still any bugs/issues after the revert we should be aware of?
     
    Last edited: Nov 10, 2022
  20. goodnewsjimdotcom

    goodnewsjimdotcom

    Joined:
    May 24, 2017
    Posts:
    290
    Does the fix allow for: NEVER COMPILE on code change?

    .5 compiles, but does not crash. I want it to never compile until I hit play.

    It makes you wonder why Unity thinks it should recompile at all on code change? Compiling locks my computer up for 14 seconds, I do not want that just to save a visual studio text file.
     
  21. Menyus777

    Menyus777

    Joined:
    Jun 11, 2017
    Posts:
    21
    digiwombat, Ninquiet and pahe like this.
  22. pawelduda

    pawelduda

    Joined:
    Feb 1, 2019
    Posts:
    45
    What about 2022.1? We just migrated form 6f1 (that had some serious runtime bugs) to 22f1 only to found this issue. Is the backport planned?
     
  23. oobartez

    oobartez

    Joined:
    Oct 12, 2016
    Posts:
    143
    "Recompile After Finished Playing" was the only option that worked for our team, please bring it back.

    "Stop Playing And Recompile" shuts down the game when someone edits any script, which just doesn't make sense - you lose all your in-game progress when you accidentally make a minor fix in your code.

    "Recompile And Continue Playing" just crashes everything. I do not think it makes sense for Unity to maintain this functionality, hot recompiling is a really complicated subject and it cannot work in a real-world project unless the game developers really build the whole game with hot recompilation in mind from the ground up. It would make more sense for Unity to use those resources elsewhere.
     
  24. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    927
    I disagree, this feature is extremely useful in smaller test scenes that don't require a lot of changes to get it working.
     
  25. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    5,951
    If you have changes to which serialized fields exists, you'll have to recompile, otherwise you can't put values in there.

    It's very common for me to make a change in Rider that adds a
    [SerializeField] private
    field, go over to Unity, and then drag something into the new slot on a behavior.

    If you want refresh on external files to happen either when a) you enter play mode or b) when you hit ctrl+r, and never otherwise, that's pretty easy to achieve. Just write a script that calls AssetDatabase.Refresh on before enter play mode.
     
  26. goodnewsjimdotcom

    goodnewsjimdotcom

    Joined:
    May 24, 2017
    Posts:
    290
    Everyone knows this who turns asset refresh off(figuratively). We turn asset refresh off to save hours a week of nonsense recompiles like the one presented. To FORCE a compile on a user who explicitly does not want to waste time in nonsense compiles is logically counter intuitive, correct? I'm not the only one who disables asset refresh am I?

    I'm a top tier world class UI engineer tho, and things that are obvious to me are not to most.

    LETS GET MORE ADVANCED CLASS AND FIX UNITY'S CORE PROBLEM:

    So Unity has been doing it wrong for as long as I've been using Unity.

    Most IDE have a cycle:

    Code/Edit files/compile only when chosen.

    Unity has a weakness in that you're pandering for super noobs Users (understandably)

    Code/Recompile on save/Recompile on file change/play has it already compiled.

    So if compilation takes 10 seconds and you edit/change 10 things, you just lost 100 seconds for no reason at all. These 100 seconds here, 100 seconds there adds up to many hours a week of lost productivity. Not only hours are lost, but if you know the psychology of a software engineer's mind, pauses are like distractions... Distractions are the bane of the coder... So you effectively reduce software engineer's ability to make product by 30-50%. Literally this is how bad Unity's cycle is.

    That said, Unity's cycle is great for BEGINNER USERS.

    There should be a check box to go to INTERMEDIATE USER once you past like a driver's/boater's exam of understanding serialized fields. This would enable my version of Unity I work in:

    I turn asset refresh off. I have a script that runs a compile when you play My code never compiles until I hit play except this bug. I understand the serialized field things, so I can be afforded saving hours a week of nonsense compiles and nonsense pauses.

    I have no idea why UNITY has not given this power to ALL users. I had to become an advanced user simply to write the script to compile on play...

    You know if you just turn asset refresh off, Unity will not refresh before play right? Leading it to be a state like you didn't save your code? That's worse than auto refreshing so many users take the abuse of nonsense compiles... So many users looking for a better way hang their head in despair and leave auto refresh on.

    Since the very first few months of Unity's release, the option for Intermediate User should have been available. You'd be doubling your user's productivity, lowering their frustration levels and bringing more brand awareness pride naturally, organically and morally.

    TO CONCLUDE:

    I have auto refresh checked knowing how serialized fields work, yet it is still trying to compile thus wasting my time. Considering post .2021.3.5f1 just crashes on debug, I'm content with at least it working a little bit. I'd love if autorefresh did what it used to and not compile on code changes, but we all know UNITY engineers messed up in a few ways here and we're forgiving. My productivity cycle is insanely superior to most Unity devs with no asset refreshes or compiles until I hit play. It isn't my problem if everyone suffers and languishes with loading bars that could be avoided...

    I provided the explanation of the problem: Wasted time compiling nonsense that doesn't need to be.

    I provided what the problem does: Wastes hours of devs times a week, and up to halves their productivity.

    I provided the solution: A check box to enter Intermediate Unity user mode which does not refresh until play is hit.

    I explain this larger problem has been around since UNITY started and no one seems to notice though raising your user base's productivity and getting them thousands of hours of dev time seems pretty major. But that's unity's concerns, not mine,for I coded my version of unity so it does this. Of course we know how asset refresh works. Does Unity know their user's knowledge and wants/desires for a better product?
     
    Last edited: Nov 14, 2022
  27. goodnewsjimdotcom

    goodnewsjimdotcom

    Joined:
    May 24, 2017
    Posts:
    290
    For everyone who wants to have my sleek "Never compile/asset refresh til play"
    Slap this Script in assets/editor, then turn asset refresh off in preferences.
    Now instead of hitting play button, use hotkey f12 to play and stop your program.
    I am not advanced enough to turn the play button click into this code,but hotkeys are faster for devving anyway. To populate your serialized fields, just tap f12 twice or alt+r or whatever your refresh assets is.


    using System;
    using System.IO;
    using System.Text;
    //using UnityEngine.SceneManagement;
    using UnityEngine;
    using UnityEditor;
    using UnityEngine.Events;
    using UnityEngine.Scripting;
    using UnityEditorInternal;
    using UnityEditor.Scripting;
    using UnityEngine.TestTools;
    using Unity.Profiling;
    using UnityEditor.Profiling;
    //using UnityEngine.SceneManagement;
    using UnityEditor.VersionControl;
    using UnityEngine.Profiling;
    using System.Reflection;

    public static class GlobalKeyEvents
    {
    // Exposed delegates to hook up your methods to them.
    public static event Action<KeyCode, EventModifiers> GlobalKeyDown;
    public static event Action<KeyCode, EventModifiers> GlobalKeyUp;
    public static event Action AnyShortcutTriggered;

    [InitializeOnLoadMethod]
    private static void EditorInit()
    {
    RegisterToGlobalEventHandler();
    RegisterToTriggeredAnyShortcut();
    }

    private static bool OnAnyShortcutTriggered()
    {
    AnyShortcutTriggered?.Invoke();
    return true;
    }

    private static void RegisterToGlobalEventHandler()
    {
    FieldInfo info = typeof(EditorApplication).GetField("globalEventHandler", BindingFlags.Static | BindingFlags.NonPublic);
    EditorApplication.CallbackFunction value = (EditorApplication.CallbackFunction)info.GetValue(null);
    value += OnGlobalKeyPressed;
    info.SetValue(null, value);
    }

    private static void RegisterToTriggeredAnyShortcut()
    {
    FieldInfo info = typeof(EditorApplication).GetField("doPressedKeysTriggerAnyShortcut", BindingFlags.Static | BindingFlags.NonPublic);
    Func<bool> value = (Func<bool>)info.GetValue(null);
    value += OnAnyShortcutTriggered;
    info.SetValue(null, value);
    }

    private static void OnGlobalKeyPressed()
    {



    if (Event.current.type == EventType.KeyDown)
    {

    KeyCode key1 = Event.current.keyCode;


    switch (key1)
    {
    //case KeyCode.W:
    //Debug.Log("W!");
    /// break;
    case KeyCode.F12:
    case KeyCode.F11:
    //case KeyCode.F10:
    //case KeyCode.F9:
    {

    if (Application.isPlaying)
    {

    #if UNITY_EDITOR
    UnityEditor.EditorApplication.isPlaying = false;

    #endif


    }
    else
    {
    UnityEditor.AssetDatabase.Refresh();
    UnityEditor.EditorApplication.EnterPlaymode();
    }


    }
    break;

    }





    GlobalKeyDown?.Invoke(Event.current.keyCode, Event.current.modifiers);
    }
    else if (Event.current.type == EventType.KeyUp)
    {
    GlobalKeyUp?.Invoke(Event.current.keyCode, Event.current.modifiers);
    }
    }
    /*
    public class DisableUnityMenuItems : Editor
    {
    [MenuItem("MainMenu/Edit/Play")]
    static void aa()
    {
    }
    }
    */
    }
     
    Ninquiet likes this.
  28. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    2,795
    You forgot code tags Mr world class UI engineer.
     
    pahe, samfss, Shizola and 2 others like this.
  29. tetto_green

    tetto_green

    Joined:
    Dec 22, 2015
    Posts:
    32
    I must admit you seems the most helpful Unity specialist I have ever met on these forums! Thank you so much!
     
  30. mschweitzer-nflx

    mschweitzer-nflx

    Joined:
    Oct 24, 2022
    Posts:
    1
    We need this in 2022.1 as well. Was this an oversight or not yet merged?
     
  31. PeraSite

    PeraSite

    Joined:
    Jul 3, 2020
    Posts:
    2
    I downloaded 2021.3.14f1 release, and can confirm that the option is came back.
    But it has still "fake compile alert" that is very annoying.
    I will gonna stick to the PreventAutoRefreshWhilePlaying script that doesn't have fake alert.
    Please fix, Unity.
     
  32. Thomas-Bousquet

    Thomas-Bousquet

    Joined:
    Dec 19, 2016
    Posts:
    19
    @jdrewsen
    I tested in 2021.3.14f1, and there are 2 fairly serious bugs.
    I reported them and provided a skeleton project as well as repro steps and expected/desired behaviour for them.

    1. Case IN-23516: When Asset Pipeline/Auto Refresh is set to Enabled, C# changes trigger a recompile while playing even if Script Changes While Playing is set to Recompile After Finished Playing

    2. Case IN-23518: When Asset Pipeline/Auto Refresh is set to Disabled, Script Changes While Playing value is completely ignored.

    I would request to please, add them in the Known Issues section of the Release Notes.
     
    Last edited: Nov 20, 2022 at 10:01 AM
    greg-harding likes this.
  33. greg-harding

    greg-harding

    Joined:
    Apr 11, 2013
    Posts:
    505
    Yep, same here. I tested 2021.3.14 on Mac and it does not seem to fix things.
     
  34. moonlessformless

    moonlessformless

    Joined:
    Dec 21, 2017
    Posts:
    4
    2021.3.14 does fix things, at least for me(on Windows). Auto Refresh Enabled, and Recompile After Finished Playing - works as expected.

    There is a brief "fake" compiling scripts dialog, as noted by PeraSite above, but the scripts are not actually recompiled and your play session continues as normal. Is it possible Thomas/greg are getting fooled by this?

    Thank you for restoring this feature! Much appreciated.
     
  35. greg-harding

    greg-harding

    Joined:
    Apr 11, 2013
    Posts:
    505
    The popup dialog seems real and a compile does happen, logging the usual warnings and errors to the console while playmode is stalled for 15-20s while it compiles.
     
  36. Thomas-Bousquet

    Thomas-Bousquet

    Joined:
    Dec 19, 2016
    Posts:
    19
    I've rechecked that my repro steps are correct, and on my end they are.
    I've sent a DM to @moonlessformless to check if they can follow them on their side in order to make sure check it isn't some phantom registry value messing this up on my end.
    I'll update this thread with the result if they come back to me.
     
  37. Thomas-Bousquet

    Thomas-Bousquet

    Joined:
    Dec 19, 2016
    Posts:
    19
    So I got an answer for "Case IN-23516". It acknowledges that Script Changes While Playing is basically ignored if "Asset Pipeline/Auto Refresh” is set to Enabled
    subsequently they closed the report as Not Qualified.*siiiiiiigh*
    I've put a comment to reopen it because it's definitely not the expected behaviour.
    The other report is still in review. I'm going to take a looong walk now.
     
    Last edited: Nov 24, 2022 at 1:29 PM
  38. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    927
    What a mess...
     
unityunity