Search Unity

Ghost Objects in YAML Scene files

Discussion in 'Editor & General Support' started by JerrodStorm, Nov 18, 2020.

  1. JerrodStorm

    JerrodStorm

    Joined:
    Dec 13, 2018
    Posts:
    4
    When looking at my scene files in a text editor, I'm seeing objects that are no longer part of the scene (and haven't been for at least a day).

    ---

    The other night I created a whole bunch of unity scenes that a player is supposed to be able to explore, with cross scene loading between them (imagine a player interacting with a door and walking off-screen, then the next scene loads with the player placed at a spawn point).

    As part of building the scenes, I would sometimes create a new empty scene, drag the contents of an existing scene into the new scene, and then revert changes on the old scene, resulting in a duplicate of the old scene that I could make small adjustments on.

    However, now that I'm testing out moving from scene to scene, my scene transitions are breaking, claiming to be loading a new scene that the previous scene has literally no reference to in the hierarchy, and failing to load even when that (definitely wrong) scene exists and is in build settings.

    So I opened up the YAML (text-based) scene files to find "ghost-objects," doors and scene transition objects that aren't in the hierarchy on load, but existed when I first created the copy (but then deleted or modified), and which are still being used during play mode. What's more, these "ghost" objects come and go from the file, like there's some kind of link with the scene it had originally been copied from. This is true even if I unpack the prefabs that are shared between those two scenes.

    Here's an example of one of the ghost objects:

    --- !u!114 &1693613283413300282
    MonoBehaviour:
    m_ObjectHideFlags: 0
    m_CorrespondingSourceObject: {fileID: 0}
    m_PrefabInstance: {fileID: 0}
    m_PrefabAsset: {fileID: 0}
    m_GameObject: {fileID: 1693613283413300283}
    m_Enabled: 1
    m_EditorHideFlags: 0
    m_Script: {fileID: 11500000, guid: f39156e897c6fb94a98e07f58aa0fb9a, type: 3}
    m_Name:
    m_EditorClassIdentifier:
    scene:
    m_SceneAsset: {fileID: 0}
    m_SceneName: village_artisan_square_south_outside
    spawnPoint:
    sceneName:


    "village_artisan_square_south_outside" should actually be "village_south_entrance_by_cottage" based on what's in the hierarchy.

    Has anyone ever run into something like this? Is there a way to "clean" unity scenes (i.e., force a rewrite of the scene file that only contains what's actually in the hierarchy)?
     
    contactjakemb likes this.