GithubHelp home page GithubHelp logo

ertanturan / unitydebug Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joebrogers/unitydebug

0.0 0.0 0.0 69 KB

A wrapper script for Unity debug calls to use conditional attributes in order to avoid debug code being compiled into release builds.

License: MIT License

C# 100.00%

unitydebug's Introduction

Maintenance License Ask Me Anything ! Twitter Follow Made With Unity

UnityDebug is a small script to wrap Unity's Debug logging calls to enforce strict calling intent on which debugging calls make it into compiled builds.

How does it work?

The script contains a static class InternalDebug, wrapping all UnityEngine.Debug calls with conditional attributes. Any calls made from this class will only be preserved when the project is built with the "Development Build" option checked in the "Build Settings" window, (or alternatively, the Development flag set in BuildOptions).

Why would I need this?

It's a common misconception for newer developers working with Unity to expect debug calls to be stripped out of game builds. This is not the case. It's all too easy to leave debug calls lying around within your scripts, that will be using up potentially precious performance under the hood (that Debug.LogWarning you left in Update is really going to come back to bite you).

Even for experienced developers, there's definite distinction between the debug calls you utilise during every day development and those you want to ship with final builds in order to aid in debugging user-submitted bugs. It can quickly become a cumbersome annoyance to find+comment/uncomment these calls, or even strip and replace every time you need to build.

By utilising a script like this, it'll not only save you work by automatically stripping out internal debug calls, but it's also explicit about the intent of particular logs. Being able to immediately discern the intent of particular calls, especially in a team environment is a big aid in streamlining the shipping process.

Things to know

There are two variants of this script you can use, one of which is the raw .cs file, which can be found in the src folder. The other, is a .dll file of the compiled script, which can be found in bin. The difference here, is that when using the raw script version, double-clicking on the logged message in the console window won't jump you to the line referred to, but rather the debug script. Using the compiled .dll file circumvents this issue.

Also, unlike the traditional Unity methods, there are also overloaded versions of all Log methods which take in a conditional argument (defaults to true). Allowing you to pass in your conditions, rather than wrapping your method calls - in turn, doing things this way also means that the condition itself is stripped from the build.

How do I use this?

It's as simple as dropping either the script file or .dll into your project window and replacing any calls to Debug. (or UnityEngine.Debug.) with InternalDebug. (or Utilities.InternalDebug. if you don't include the namespace). The arguments have been left as-is, with any additions being made as overloads, so nothing should need to change about your current project set up at all.

Enjoy!

unitydebug's People

Contributors

joebrogers avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.