Search Unity

Bug Scene deleted when imported a package

Discussion in 'Package Manager' started by emildraganm, Dec 1, 2022.

  1. emildraganm

    emildraganm

    Joined:
    May 7, 2019
    Posts:
    19
    Hi,

    I am posting here my problem because it happened when I imported a package.

    I had a scene and everything was ready, I was working on it for 2 weeks. I imported from the assetstore a package with a terrain, and after that, my current scene is gone, it was replaced with the scene from that package.

    Now, when I open my scene, it opens that scene, so all of my work is gone. I deleted the package, so my scene now it s empty.

    I am using Unity 2022.1.16f1. I don t see any solution for getting my scene back.

    Maybe it s because the scenes had the same name, SampleScene, but this thing shouldn t happen.

    If someone encountered this problem before, please let me know because it s very urgent.

    Thank you.
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,403
    yes, importing packages (mainly their samples) can overwrite that SampleScene or other files (if same name, location).

    no way to restore it, unless you notice it immediately and haven't pressed play with new scene,
    then old last played scene can be inside "ProjectFolder/Temp/__Backupscenes/0.backup"

    Can try using undelete tools to recover, but not sure what you can get back, if that file is overwritten many times now.
    (if you have mac, it has some timemachine feature?)

    Only real solution for these is version control and or backups..
     
    abdullahashraf241 likes this.
  3. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,835
    This probably happened because you started working with the scene provided by the package. Merely moving it to some other location in the folder hierarchy and renaming it won't break that reference, the package still "owns" that scene and when the package is updated and contains a SampleScene change, it will overwrite it.

    The solution for cases like these is to select a scene of a package and duplicate it (Ctrl+D / Cmd+D) and edit only the duplicate.
     
  4. emildraganm

    emildraganm

    Joined:
    May 7, 2019
    Posts:
    19
    Thank you for the response, but this is not the case. I had a scene, after 2 weeks (today) I imported a package, immediately after importing, my scene was replaced with that scene. The only thing I could think is that it happened because the scenes had the same name, as I mentioned, but still, I did this thing hundreds of times until now, starting with a scene named SampleScene and at some point importing assets with scenes called also SampleScene, but nothing happened.
     
  5. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,835
    The name is irrelevant, also the location doesn't matter. What is relevant is the GUID of the asset, which is encoded in the .meta file. The AssetDatabase is a database that indexes all assets by GUID, never by name or folder. See this article.

    So if importing a package overwrites an asset that you edited, it is because the asset you were editing had the same GUID as the asset in the package. For that reason it seems almost certain that you were using the original scene provided by the package, and moved it around and renamed it, rather than duplicating that scene or working in a newly created scene.
     
  6. emildraganm

    emildraganm

    Joined:
    May 7, 2019
    Posts:
    19
    Thanks again for response, it makes sense what you're saying, I read the article, normally this would be the answer, but I am sure it was the opposite.
    First, I worked on my project without any imported assets, then I needed a terrain and I imported this asset.

    Martian surface - rocky area | 3D Sci-Fi | Unity Asset Store