Game Development Reference
In-Depth Information
Debugging with MonoDevelop - call
stack
More complex programs typically involve lots of functions and function calls.
During execution, functions can invoke other functions, and these functions can go on
to invoke yet more functions in an intricate chain of functions within functions. This
means that when setting breakpoints inside functions, you can never know how the
function was invoked initially when it's actually called at runtime. The breakpoint tells
you that program execution has reached the specified line, but it doesn't tell you how
execution arrived there in the first place. Sometimes, it might be easy to deduce, but at
other times it can be much harder, especially when functions are invoked within loops,
conditionals, and nested loops and conditionals. Consider the following code sample
2-10, which has been amended from the earlier code sample 2-9. This class contains
several functions that invoke other functions:
using UnityEngine;
using System.Collections;
public class DebugTest : MonoBehaviour
{
// Use this for initialization
void Start ()
{
//Get all game objects in scene
Transform[] Objs =
Object.FindObjectsOfType<Transform>();
//Cycle through all objects
for(int i=0; i<Objs.Length; i++)
{
//Set object to world origin
Objs[i].position = Vector3.zero;
}
//Enter Function 01
Func01();
}
//-------------------------------------
//Function calls func2
void Func01()
{
Func02();
}
 
Search WWH ::




Custom Search