I have been working on a chess game on Unity 5. It works correctly when testing, but after I build to web or exe, and run the game, every time I click a piece, the console spits out
“UnityException: GameObject has undefined tag!”
But I checked, all the pieces are tagged, and this is not an error that ever occurs when playing in development mode?
Anyone have any ideas on how to narrow down what’s causing this/how to fix? I’m very new to unity (this is only my second project) and would love to get this working.
I was seeing the same error message when running on Android, but not within the editor. The same logic error was occurring on iOS, but I haven’t checked the logs to see if this was the exact error message.
This particular project was upgraded from Unity 4 to Unity 5.6.1f1. What I found is that in Project Settings | Tags and Layers there were a few tags marked as “Removed”, and a message from Unity stating that they would actually be removed the next time the project was loaded. Unfortunately, reloading the project would never remove them.
My hunch was that Unity was in a state where it thought the tags were up to date, and that there was nothing to do to them at project load.
The answer was to add a temp Layer, save the project, then reload the project. I restarted Unity just to be safe. The “Removed” tags were then actually removed, and everything is now working properly on Android builds. I’ll test iOS as well, but I would bet money it’s fixed as well.
My assumption is that making a change (adding a layer) marked a dirty flag internally and Unity’s cleanup logic at project load now saw that there was a change to the Tags and Layers and did it’s normal processing. The tags probably got screwed up when upgrading the project from Unity 4 to Unity 5. That I don’t know. The tags look fine in Unity 4.
Afterwards, I did of course remove the temp layer.
I had a similar problem. It seemed to just be one function in the game that wasn’t working.
Turned out I had a bunch of empty scripts in my game on a prefab which was giving console errors. Was something I’d neglected to solve earlier. Don’t know how, but that solved it. Hope that helps.