I’m modding a game, and I’ve run across a problem. I’m trying to draw text to the screen in C# with .NET and XNA, so i’m using XNA’s SpriteBatch.
The problem is, I can’t modify any source files. I can only load external .cs files. I can LOOK at the source, and the variable is defined as so in the class Main.cs:
private SpriteBatch spriteBatch;
If I define my own SpriteBatch as so:
public SpriteBatch spriteBatch;
then it doesn’t draw, because I don’t have a draw method. Now, all I want to do is access Main.spriteBatch, but that variable is private as mentioned before.
Any ideas?
You can use reflection to retrieve the value of private variables or methods.
http://www.csharp-examples.net/reflection-examples/
To invoke with arguments, pass a array of the arguments in instead of null.
Link to further documentation from the msdn.