Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Debugging help

Discussion in 'Scripting' started by pitso 7, May 24, 2012.

  1. pitso 7

    pitso 7

    Joined:
    Apr 4, 2012
    Posts:
    67
    Hi all im new to coding so I don't know much. I been coding maybe 3 weeks now I learn some things. I am learning by myself. On my own time and I dont know much about debugging. How does it really help. How can I use it and I think this is the right place to place this thread. if you got any ideas on how to help me plz post. If you got any tips that be great to and no negative comments im new sorry if this is a stupid question.
     
    Last edited: May 27, 2012
  2. Zethariel1

    Zethariel1

    Joined:
    Mar 21, 2012
    Posts:
    439
    The debugger is the obnoxious little box that pops up whenever there is an error in your code. It is handy in the way that it runs through your code, looks for unused references, syntax errors and other shenanigans your brain tried to feed you.

    The process of debugging is simply getting rid of those bugs, or fixing functions when they don't work as you intended them to. A real-life example of debugging is, for example, fixing a PC. You check all the components, run various checking software (debuggers) and act accordingly.

    The best way you can use it is to actually read and understand it. Most of the time, the debugger tells you in plain English what is wrong and what you should change. Sadly to say, some users don't do that, post their error messages and get ridiculed or receive a translation from English to English of what Unity is trying to say.

    Not to say that coming here with a problem is wrong -- especially if you are stumped on a problem. Just make sure you read what the debugger threw at ya, and google all the words and definitions you don't understand. 95% of the time you can fix things on your own, and the errors are trivial (mis-matched types, illegitimate casting, missing components or variables).

    Good luck!
     
  3. Metalero91

    Metalero91

    Joined:
    Mar 19, 2012
    Posts:
    83
    That's not a debugger. That's just the Console window.
    As Zethariel said, console window shows you errors (and wanings) and it's useful to fix bugs, but it's still not a debugger.

    A debugger is a tool that lets you to stop (and continue) the flow of the code, and inspect the variables' values when you stop the program.
    This tool is available inside MonoDevelop (you have to attach MonoDevelop to unity, using the attach button), place your breakpoints where you want, and tun the game (from unity)
     
  4. pitso 7

    pitso 7

    Joined:
    Apr 4, 2012
    Posts:
    67
    how can i use the debugger and ya i know how to use the console window 50% of the time i can fix my problems it just takes time
     
  5. Metalero91

    Metalero91

    Joined:
    Mar 19, 2012
    Posts:
    83
    -Go to MonoDevelop (and be sure to have the unity project open)

    -Run/AttachToPrecess -> and select " Unity Editor (Unity) "

    -Put breakpoints where you want.

    -Run the game from unity.
     
  6. Integria

    Integria

    Joined:
    May 12, 2012
    Posts:
    145
    To iterate slightly on the above;

    When you reach a breakpoint in the code, execution will stop. What this essentially allows you to do is to check the 'state' of your script at that point in time; what values do variables hold, and such.
     
  7. pitso 7

    pitso 7

    Joined:
    Apr 4, 2012
    Posts:
    67
    lol how do i add breakpoints
     
  8. Integria

    Integria

    Joined:
    May 12, 2012
    Posts:
    145
    Click the left mouse button on the line where you want to set one (actually, slightly to the left of where line-numbers appear).
     
  9. pitso 7

    pitso 7

    Joined:
    Apr 4, 2012
    Posts:
    67
    i tryed it didn't work its with the red cycles right on the left when you do everything it says breakpoints