Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs

Life-Saving Tip for Debugging Unity Games

A topic by DStecks created Nov 28, 2018 Views: 124 Replies: 4
Viewing posts 1 to 3

Just felt like posting this here because it's something that apparently some people don't know about, and I have no idea how I would work in Unity without it.

When messages show up in the Console, if you select a message, the window beneath the console will show the complete call stack, with line numbers for where the call occurred. Line-by-line debugging in Unity sucks, so this is the next best thing.

This has loads of applications beyond finding the lines causing bugs. If you want to know where a variable is being modified from, you can wrap it in a C# Property, then make the variable private so it can only be accessed via the property, then put a Debug.Log() in the property's Get function.

(+1)

In my honest opinion the worst thing about Unity is that it gets touted as being usable to people with no programming experience. Because it sort of is, you can definitely make stuff work with only a beginner level of coding knowledge, but unless you've got an actual background in programming, a lot of stuff is going to be completely invisible to you, especially when things go wrong.

I started putting in what I call my "dev gui" for the build just to make sure everything is working. I recently had a problem where everything worked in the editor, but there were problems with the build, so I stuck in a bunch of Debug.Log for while I was running in the editor, and I also had it write it to a gui in world space but outside of camera view, then I just did a keypress listener to move that gui in and out of the camera view. I found the problem lickety split. So now I use it all the time. It's not the ideal solution, but it less time consuming than digging thru the app data to find the problem

(+1)

It is really demented that Unity doesn't have a built-in dev console accessible in builds. This isn't the kind of thing that should need to be hacked together by the end-user, it's an industry standard feature.

I guess there is some third party stuff but this was quicker