Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Undo crashes Unity 2021.3.9+

Discussion in 'Editor & General Support' started by Rowlan, Oct 6, 2022.

  1. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
    Here's a repro case. Drag a prefab into the prefab field in the inspector, click "Add Prefab" and hit ctrl+z => Unity will crash.

    Code (CSharp):
    1. using UnityEngine;
    2. #if UNITY_EDITOR
    3. using UnityEditor;
    4. #endif
    5.  
    6. public class UndoExamples : MonoBehaviour
    7. {
    8.     public GameObject prefab;
    9.  
    10. #if UNITY_EDITOR
    11.     [CustomEditor(typeof(UndoExamples))]
    12.     public class UndoExamplesEditor : Editor
    13.     {
    14.         public override void OnInspectorGUI()
    15.         {
    16.             DrawDefaultInspector();
    17.  
    18.             if (GUILayout.Button("Add Prefab"))
    19.             {
    20.                 GameObject instance = PrefabUtility.InstantiatePrefab((target as UndoExamples).prefab) as GameObject;
    21.                 instance.transform.position = Vector3.zero;
    22.  
    23.                 instance.transform.parent = (target as UndoExamples).transform;
    24.  
    25.                 Undo.RegisterCreatedObjectUndo(instance, "Instantiate Prefab");
    26.  
    27.             }
    28.         }
    29.     }
    30. #endif
    31. }
    @LeonhardP tagging you since this seems rather serious. It's still happening in 2021.3.11f1. I created a ticket IN-18802.
     
    mawa_tari likes this.
  2. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    595
    mawa_tari and Rowlan like this.
  3. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
    Thanks. Those versions should have never seen the light of day. I mean bugs are bugs, but all changes lost because you press ctrl+z is definitely a blocker. Especially when it's an LTS.
     
    Last edited: Oct 6, 2022
    mawa_tari likes this.
  4. mawa_tari

    mawa_tari

    Joined:
    Feb 9, 2017
    Posts:
    3
    I'm having the exact same problem.

    In Unity2021.3.11f1, I posted a gif file of the situation where a bug occurs from a new project.

    I would appreciate it if someone could refer to it.

    Unity2021.3.11f1_undo_bug.gif
     
    Edy likes this.
  5. mawa_tari

    mawa_tari

    Joined:
    Feb 9, 2017
    Posts:
    3
    We have confirmed that this bug has been fixed in Unity2021.3.12f.1.
    (I have attached a gif to confirm that this bug has been fixed.)

    Here is the IssueTracker for this bug fix.

    I had to update to "Unity2021.3.11f.1" (or higher version) which fixed a bug in WebRequest, so it was very helpful.

    Thank you!

    unity2021-3-12f1_fixed_undo_bug-gif.gif
     
    Last edited: Nov 28, 2022
    Rowlan likes this.
  6. ForceVII

    ForceVII

    Joined:
    Apr 18, 2020
    Posts:
    2
    I have this issue in every 2021 version even the LTS! Even the Unity2021.3.11f1 you use
     
  7. mawa_tari

    mawa_tari

    Joined:
    Feb 9, 2017
    Posts:
    3
  8. Kek_Leon

    Kek_Leon

    Joined:
    Dec 11, 2022
    Posts:
    1
    It's already 2023 and it's still an issue, I tried the autosave feature but it's still not enough. It's very disappointing losing hours of progress.
     
  9. MaciekOaky

    MaciekOaky

    Joined:
    Nov 10, 2016
    Posts:
    6