I would like to display the current value of a class on screen for debugging purposes. For example, if I am dealing with the this class
public class Foo
{
public bool isSexy;
public Foo()
{
isSexy = false;
}
}
and I wish to display the boolean parameter on screen how could I do that and have it automatically updated when its value changes?
I have a separate class that has a method of storing any parameter thrown at it in a dictionary
Dictionary<string, object> debugParams = new Dictionary<string, object>(15);
Any parameter is added to the dictionary with this method
public void AddParameter(string paramName, object param)
{
debugParams.Add(paramName, param);
}
and displayed with this method
foreach (KeyValuePair<string, object> kvp in debugParams)
{
position.Y += 15;
string stringCurrent = string.Format(kvp.Key + ": {0}", kvp.Value);
spriteBatch.DrawString(font, stringCurrent, position, Color.White);
}
When adding parameters to the dictionary they don't update when the original parameter updates.
For example
Foo foo = new Foo();
debug_Tools.AddParameter("Foo is feeling good?", foo.isSexy);
foo.isSexy = true;
will display false, even though the parameter has been changed to true.
How can I fix this?