Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

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

    Sukirii

    Joined:
    Oct 14, 2020
    Posts:
    15
    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.