Search Unity

(Case 1089930) Cannot delete prefab from scene

Discussion in 'Prefabs' started by DougRichardson, Oct 11, 2018.

  1. DougRichardson

    DougRichardson

    Joined:
    Oct 7, 2017
    Posts:
    74
    I put a prefab with many nested game objects and prefabs into a scene. After having some problems with the prefab performance, I decided to delete the prefab and take a different approach. However, when I pressed Delete, I got the following error and the scene would not save:

    Code (txt):
    1. Failed to create Object Undo, because the action is too large. Clearing undo buffer
    2. UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
    I'm on 2018.3.0b5.
     
  2. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    639
    I am curious. Was the prefab actually deleted but no Undo recorded? or it also fail to delete the prefab.

    I would expect the former.
     
  3. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    Thanks a lot for your report! We were able to reproduce the issue.

    Here's the issue tracker entry:
    https://issuetracker.unity3d.com/is...size-is-large-and-undo-object-cant-be-created
     
  4. DougRichardson

    DougRichardson

    Joined:
    Oct 7, 2017
    Posts:
    74
    It also failed to delete the prefab. To clarify, visually in the Hierarchy, the prefab was removed. But that change was not actually saved to disk (even after selecting File > Save).
     
  5. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    639
    Ok, so to clarify, when you deleted the prefab from the scene, it was delete but the little asterisk (*) was not added to the scene header and thus the scene was not saved?

    Sounds like a bug in the undo system. Scene dirtiness is tracked through the undo system and only if undos are recorded will the scene be marked dirty. If an undo is abandoned because memory limits we should obviously still mark the scene dirty.

    The work around for now would be make the scene dirty by doing some other change to the scene.
     
  6. DougRichardson

    DougRichardson

    Joined:
    Oct 7, 2017
    Posts:
    74
    Exactly. And I think your workaround will work. I haven't tried it with this exact problem, but I ran into another situation yesterday where the scene wasn't correctly marked as dirty (again, no asterisk) but making another scene modification (e.g., create empty, delete empty) allowed me to save it.
     
  7. DougRichardson

    DougRichardson

    Joined:
    Oct 7, 2017
    Posts:
    74
    Tangentially, I'm not sure if the core editor code itself relies on EditorUtility.SetDirty, EditorSceneManager.MarkSceneDirty, and Undo.RecordObject to mark the scene as dirty, but if those are the only mechanism it seems like an easy thing to screw up (since piece of code that touches the scene has to do the right thing). While I understand you generally want a higher level Undo associated with scene edits, even more important (to me) is that the scene changes I make get recorded reliably, so perhaps a backup mechanism should exist to determine dirtiness (e.g., a merkle tree of the game objects).