Search Unity

Tips and tricks to debug in Unity

Discussion in 'Scripting' started by JuanGomez, Apr 25, 2014.

  1. JuanGomez

    JuanGomez

    Joined:
    Nov 20, 2013
    Posts:
    10
  2. A.Killingbeck

    A.Killingbeck

    Joined:
    Feb 21, 2014
    Posts:
    483
    Yes, debugging via code
     
  3. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    10,067
    That's a good article, especially the mentions of Test Driven Design and inspector Debug mode.

    I wanted to add that you can use rich text in the console, which allows you to color-code log messages:
    Code (csharp):
    1.  
    2. Debug.Log("<color=yellow>AI message: Acquiring new target</color>", this);
    3. Debug.Log("<color=cyan>Network message: Lost connection to server</color>", this);
    4.  
    Also: http://devmag.org.za/2012/07/12/50-tips-for-working-with-unity-best-practices/
    This is an older article, but it's still very valid. The section on Testing and Debugging, such as graphical loggers and HTML loggers, are particularly relevant to this thread.
     
  4. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,189
    When in doubt print it out!
     
  5. Tiki

    Tiki

    Joined:
    Mar 3, 2013
    Posts:
    299
    This is pretty complete... Debug.Log prints and temporary public inspector variables to save you time.
     
  6. tectuma

    tectuma

    Joined:
    Nov 26, 2012
    Posts:
    46
    Two huge ones for me... Keep your LOGS clean!!! Then you can just toss in a print or debug and fined them right away, rather than sift thru 10000 lines to find what your looking for. I had an art teacher that told me once make your change then remove. Works for coding I will copy a line of code rem one out and then make my changes. That way if I mess it up more, need to see what I did last time etc... it is right there. You can all ways remove them later.
     
  7. Prodev101

    Prodev101

    Joined:
    Aug 6, 2010
    Posts:
    49
    I've also just started using a asset called rock info.. Works great for the fps I'm developing as I can give each bot it's own channel etc..
     
  8. Juan73908

    Juan73908

    Joined:
    Aug 20, 2013
    Posts:
    13
    Wow, I didn´t know that! Definitively a must when creating Debugging messages for another person :D
     
  9. Seyed_Morteza_Kamaly

    Seyed_Morteza_Kamaly

    Joined:
    Nov 18, 2015
    Posts:
    69
unityunity