x


How to debug code (JavaScript)

Is there something in Unity for stopping the code while it is executing in some pre-determined points and then verify the value of whatever variables at that time and then keep on moving? Something like what VBA for Excel has.

I ask this because I want to do something in the Update() function, but it doesnt do what I want, but when I try to see what is going on, the Update function doesnt stop, all I can get is whatever I put in the log.

Is not any way of stopping it (other than the stop or pause button) and check what the current values are?

more ▼

asked Mar 10 '10 at 06:18 AM

pyocote gravatar image

pyocote
22 1 1 1

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

As well as using Debug.Break() to pause the editor, you can also switch the Inspector pane to "Debug Mode" which shows up all the variable values for the selected object, including private vars, so you can examine their values.

To switch the Inspector pane to Debug mode, look for the small dropdown menu icon to the left of the "Inspector" tab, at the very top of the pane.

more ▼

answered Mar 10 '10 at 08:10 AM

duck gravatar image

duck ♦♦
41k 92 148 415

The Inspector has a Debug mode, and shows private variables? Excellent! Here, have a +1. (And because you need more points - I hear at 10K, you get a free toaster-oven. :)

Mar 10 '10 at 02:41 PM Cyclops

A toaster-oven? I thought it was a luxury cruise! All that effort, wasted!

Mar 10 '10 at 03:23 PM duck ♦♦
(comments are locked)
10|3000 characters needed characters left

Use Debug.Break(), which pauses the editor. Or, if you have "Error pause" selected in the console, you can use Debug.LogError(), which will also pause the editor.

more ▼

answered Mar 10 '10 at 06:53 AM

Eric5h5 gravatar image

Eric5h5
80.3k 42 132 521

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3460
x534
x239

asked: Mar 10 '10 at 06:18 AM

Seen: 2772 times

Last Updated: Mar 10 '10 at 06:18 AM