Reputation: 5384
I am calling an executable from my Unity project. The executable contains a function which works with timer (predefined time for example 10seconds). What I want is to change the functionality a little bit instead of running with a timer to give as an input to the .exe a boolean flag with which I ll be able to continue the execution of the executable or stop it. However to do so, I have to give a dynamic input to the .exe. Is is possible to do so? And if that is possible how can I do so, without spending much system resources?
EDIT:
void record(){
string[] args = { path, dataDir, Date+"\\", name, surname };
System.Diagnostics.Process.Start(execDir, String.Join(" ", args));
}
OnGUI code:
if (GUI.Button (new Rect (150,250, 100, 50), "RECORD")) {
record();
}
if (GUI.Button (new Rect (270,250, 100, 50), "STOP")) {
stop_recording();
}
This function record calls an executable which wrote several stuff to binary file. I have also a Stop button in which I want to add the flag. When the button pressed the flag will be true and I want to parse that value as argument into the execDir executable.
Upvotes: 1
Views: 233
Reputation: 10906
I think what you want to do is to pass commands onto a running console application, am I right?
First of all, it all depends on the executable you're running. If the executable exposes no controls other than a simple "time_to_run" command line argument or starts a new instance each time you run it and you don't have the sources of this executable or are unable to compile it, you're out of options. However, if you have access to the sources or have written it yourself, you can do many things.
Applications allow external controls in various ways.
Take your pick! :)
Upvotes: 1