Search Unity

Backup broke my game- Anyone see a fix?

Discussion in 'Editor & General Support' started by DrJBN, Jun 24, 2021.

  1. DrJBN

    DrJBN

    Joined:
    Sep 28, 2014
    Posts:
    49
    Yesterday I made some minor changes to my game. It was in pristine condition. I saved the scene, saved the project, saved my CS files, shut it all down. Today, I'm thinking about how pristine it is (was) and think, "I should back it up."

    So I screw up, but only mildly. I assume I screwed up, though what I did shouldn't matter, or at least I don't think it should.

    Instead of copying all my files from the game directory TLGPort to TLGPort_Backup, I accidentally moved them. Once I realize my mistake, I simply Copy the files from TLGPort_Backup back to TLGPort.

    Then I try to open the game with Unity Hub in the original TLGPort game directory. It says there are compiler errors- there were none when I closed it yesterday. I ignore them and it loads with a ton of warnings and errors. I close it down. Delete all files in TLGPort and re-copy and try to open again. Same error. I cancel. I delete the Library and try again. Same thing. This time I open in safe mode and have 3 warnings and 25 errors.

    Before I have to get drunk, recover, and dig into these and try to fix them one by one (many of which I fail to understand- e.g., type X already defines a member Y with the same parameter types, yet I look in the file and I do not see that) does anyone have any idea what might have happened and a fix?

    Unity 2021.1.7f1
     
  2. DrJBN

    DrJBN

    Joined:
    Sep 28, 2014
    Posts:
    49
    These are the warnings, which might have to do with the errors and provide some clue as to what has happened to me.

    Asset file 'Packages/com.unity.serialization/Tests/Runtime/Unity.Serialization.Tests/SerializationTestFixture.Propertypath.cs.meta' and meta file 'Packages/com.unity.serialization/Tests/Runtime/Unity.Serialization.Tests/SerializationTestFixture.PropertyPath.cs.meta' has inconsistent casing.
    Renaming meta file succeeded.

    Asset file 'Packages/com.unity.serialization/Tests/Runtime/Unity.Serialization.Tests/SerializationTestFixture.Propertypath.cs.meta' and meta file 'Packages/com.unity.serialization/Tests/Runtime/Unity.Serialization.Tests/SerializationTestFixture.PropertyPath.cs.meta' has inconsistent casing.
    Renaming meta file succeeded.

    Class HashSetExtensions can not exist in multiple namespaces in the same file, even if one is excluded with preprocessor directives. Please move these to separate files if this is the case.

    along with a sample of errors being produced.

    Assets\Outcomes\Setllarian\BeamStatic.cs(5,14): error CS0101: The namespace '<global namespace>' already contains a definition for 'BeamStatic'
    Assets\Sci-Fi Arsenal\Sci-Fi Effects\Scripts\SciFiBeamStatic.cs(5,14): error CS0101: The namespace '<global namespace>' already contains a definition for 'SciFiBeamStatic'
    Assets\Sci-Fi Arsenal\Sci-Fi Effects\Scripts\SciFiLightFlicker.cs(4,14): error CS0101: The namespace '<global namespace>' already contains a definition for 'SciFiLightFlicker'
    Assets\Outcomes\Setllarian\BeamStatic.cs(41,10): error CS0111: Type 'BeamStatic' already defines a member called 'Start' with the same parameter types
    Assets\Outcomes\Setllarian\BeamStatic.cs(47,18): error CS0111: Type 'BeamStatic' already defines a member called 'OnEnable' with the same parameter types
     
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    It sounds like you ended up with duplicates of files, like at some point you moved the files, and when you copied them to your backup you ended up with duplicates there from a previous backup, and then copied back the duplicates. I'd go to the backup and try to find the duplicates you don't want, remove them, and copy back your good code and meta files without duplicates and try again.

    When I make a backup, I avoid this kind of issue by just making a zip file of the entire project folder. No real possibility of mistakes. For serious projects I've put a lot of work into, I use source control though. If you use source control, that means to resolve a worst case scenario is just delete your project folder and check it out from source control again. Problem solved.
     
  4. DrJBN

    DrJBN

    Joined:
    Sep 28, 2014
    Posts:
    49
    Thanks for the suggestion- I'll give it a look and see what I find. My backup is just a windows copy/paste from one place to another and when it warns me about duplicate file names I tell it to replace files. I've got older backups on disc I can try, but will have lost my latest upgrades.
     
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,742
    I'm sorry you've had this issue. Please consider using source control in order to guard and protect your hard-earned work.

    Personally I use git because it is free and there are tons of tutorials out there to help you set it up.

    As far as configuring Unity to play nice with git, keep this in mind:

    https://forum.unity.com/threads/prefab-links-keep-getting-dumped-on-git-pull.646600/#post-7142306

    Here's how I use git in one of my games, Jetpack Kurt:

    https://forum.unity.com/threads/2-steps-backwards.965048/#post-6282497

    Using fine-grained source control as you work to refine your engineering:

    https://forum.unity.com/threads/whe...grammer-example-in-text.1048739/#post-6783740

    Share/Sharing source code between projects:

    https://forum.unity.com/threads/your-techniques-to-share-code-between-projects.575959/#post-3835837

    Setting up the right .gitignore file:

    https://forum.unity.com/threads/removing-il2cpp_cache-from-project.1084607/#post-6997067

    Generally setting Unity up (includes above .gitignore concepts):

    https://thoughtbot.com/blog/how-to-git-with-unity
     
  6. DrJBN

    DrJBN

    Joined:
    Sep 28, 2014
    Posts:
    49
    Odd thing- I backed up the game to an external hard drive on June 16. Since June 16 I have been accessing and modifying the version of my game on my hard drive, up until the problem I reported above on June 23. I loaded the backup from June 16 today and lo and behold- Unity has the same problem loading it. That is odd- the June 16 backup is the exact set of files I've been successfully loading and working on until my June 23 loading problem.
     
  7. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    So what I suspect you're doing, is you're copying files from your active project folder on top of your backup, without deleting or renaming the backup folder first. What this does is basically combine your backup with your current project folder, because any files which exist in the backup folder but not in the current version will not be overwritten.

    So if you move a script from one folder to another, and then do your backup, you end up with the current version of the script in its new location and another copy of the script and its meta file in its old location. The same thing goes for anything you have ever deleted in your current version, because they aren't deleted in the old version so still exist there.

    Don't do backups like this, you create a huge mess to untangle. All your backups you've ever made like this are likely broken.
     
    DrJBN likes this.
  8. DrJBN

    DrJBN

    Joined:
    Sep 28, 2014
    Posts:
    49
    "because any files which exist in the backup folder but not in the current version will not be overwritten."

    You very well may have hit the nail on the head there. I think I may have a hardware problem as well perhaps corrupting something that is contributing. I've 2 backups- the first that failed was from one directory on D: to another on D:. It was an overwrite of an existing backup. The other (slightly older) was on a USB hard drive, which was not an overwrite of an existing backup. If I copy the USB backup to D: (in its own folder) and try to load it, I get the errors. If I copy it to its own folder on C:, or load it directly off the USB drive, it loads fine. I appreciate your insights.
     
    Joe-Censored likes this.