- Home /
Question by
Caelorum · Mar 09, 2015 at 11:51 AM ·
c#arraysmonodevelop
How to debug values in jagged arrays?
I'm trying to learn how to debug in unity, and at the moment i'm using this code to find factorials. using UnityEngine; using System.Collections;
public class CodeExample : MonoBehaviour {
// Use this for initialization
void Awake()
{
print (Fac (-1));
print (Fac (0));
print (Fac (5));
}
int Fac(int n)
{
if (n<0)
{
return (0);
}
if (n==0)
{
return(1);
}
int result = n* Fac(n-1);
return(result);
}
While debugging, i've put the integer "result" on watch, so i can see it's changes as the Awake class iterates through the Fac() function multiple times. However when i use step into on Fac(5), result keeps staying at zero, and once Fac(5) gets to "return(result)", result is said to be 1.
However in unity it shows me 120 as the answer. So i'm just curious, how can i keep an eye on the result integer, so i can watch it's change throughout the code?
Any help is greatly appreciated :)
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Cant get Monodevolop to work 0 Answers