Hi!
There are quite a few threads already on the subject of reading external files, but I didn’t quite find anything to completely answer my question:
What would be a good way to read a bunch of values from, say, a text file during game play - really fast - like several times per second?
Would this be easier to tackle with C# or Javascript? I think I can manage to use either one, but I have very little experience with this sort of code.
Now, I know this would be almost impossible from the web player, but I’m referring to standalone games here, so there should be no problem with file access.
You would read them once and store in memory for later access, optimally in a well structured way (XML for example). Alternatively you can use a real database that handles the caching in memory internally and structuring for fast access.
File access on the harddisk at rapid frequency and low latency is not realistically possible, especially when notebooks are also added to the pool of target devices.
Thanks,
I guess I need to think of another approach for this, because I cant really just read them once - they would have to be updated all the time during the game.
If files cant be used, then the only way that comes to my mind, is to have Unity, or rather the game to talk with another (.NET?) process - the producer of those values.
But I guess this is not possible with Indie version?
You can easily talk between them independent of the license.
Use .NET sockets (a tcp socket will be fine in this case) to send data between the processes or actually just one way which makes it even simpler as you only need one sender and one listener so you don’t need any communication protocol to define who is talking right at the moment etc
The question though that springs to my mind: why do you have an external application generating the data?
Unity is .NET too, so why not use the same sources that generate it from within unity?
Thanks a lot! I will have to study a bit on the sockets - I’m originally a Java guy and I don’t know much about .NET yet.
Because I’m a n00b 
No seriously, the little program that I need to talk to from Unity, needs hardware access and I thought it would be easier to leave it outside Unity. I haven’t even written that yet - just designing.
But perhaps I underestimated Unity’s possibilities again? Is it possible to “everything” .NET allows from inside Unity or are there some restrictions?
Plugin support ie accessing C dlls would be a Pro only feature, in that case you would have to communicate through tcp actually.
But otherwise, as long its just .NET assembly functionality, you can just drop it into unity and use it. The only requirement is that it is .NET 2.0 basically (and does not use one of the few namespaces not present in mono 1.2.5)
That sounds a lot more versatile, than I dared to imagine - thanks again for the advice!