Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Bug Unity behaves very weird and incorrect, fixes when re-launching Project

Discussion in 'Editor & General Support' started by Sukirii, Jan 25, 2021.

  1. Sukirii


    Oct 14, 2020
    Hi, I think this is a bug, but I'm not sure if the error is Unity itself or Unity connecting with Visual Studio. I've had this bug twice in Unity 2018 and today again in 2020 version and this is the issue:
    Everything works fine without any error or warnings in Unity and Visual Studio. Then I add/change something in one script in Visual Studio, press "Save All" and head into Unity. Unity loads shortly and then I start the game. Something doesn't work, I change the code EXACTLY back.
    The weird thing is, that Unity throws an error which is a NullReferenceException and I found out that it was because, somehow, Unity changed (only in Play Mode, resets again in Editor Mode) the tag of multiple objects which were instantiated. However, the prefab has still the correct tag and there is no part in the code where I changed the tag to that one. But the most weird thing about it is that when I duplicate one of those objects, it will be dublicated, but with the right tag. I also had weird errors through version 2018 sometimes, but each time I fixed it by quitting Unity and re-launching the project. Then everything works without any error or warnings again.