2
\$\begingroup\$

I made a content pipeline extension (using this tutorial) in XNA 4.0 game.

I altered some aspects, so it serves my need better, but the basic idea still applies. Now I want to go a step further and enable my game to be changed during run time. The file I am loading trough my content pipeline extension is very simple, it only contains decimal numbers, so I want to enable the user to change that file at will and reload it while the game is running (without recompiling as I had to do so far). This file is a very simplified version of level editor, meaning that it contains rows like:
1 1,5 1,78 -3,6

Here, the first number determines the object that will be drawn to the scene, and the other 3 numbers are coordinates where that object will be placed.

So, how can I change the file that contains these numbers so that the game loads it and redraws the scene accordingly?

Thanks

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

The content pipeline cannot do that (without a bit of hacking about), it processes content as part of the project's build process.

Just use regular .net functions for monitoring file changes, FileSystemWatcher maybe and reading files File.ReadAllText().

\$\endgroup\$
4
  • \$\begingroup\$ I tried that, I used the code like this: if(ks.IsKeyDown(Keys.L)){ sField = File.ReadAllLines("path"); Window.Title = sField[0]; } I used this code just to see if the file is being read correctly, but the Title is not changing at all. I placed this code inside the Update function. \$\endgroup\$
    – NDraskovic
    Apr 5, 2012 at 11:17
  • \$\begingroup\$ Have you checked that the ReadAllLines code runs at all? \$\endgroup\$ Apr 5, 2012 at 11:23
  • \$\begingroup\$ At first it wasn't, I fixed that but now it throws me an error "Access to the path '....' is denied." (when I try to load from my desktop or similar location) or FileNotFound error (when I try to place the file inside the project directory) \$\endgroup\$
    – NDraskovic
    Apr 5, 2012 at 11:48
  • 1
    \$\begingroup\$ That's an issue with the access rights of the user the program is running as I would think. Maybe ask a question on stackoverflow.com (as it's no longer related to game development). \$\endgroup\$ Apr 5, 2012 at 12:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .