- Home /
Open External Program - Unity 5
I already know how to run an external program within unity using Code (CSharp): System.Diagnostics.Process.Start("C:/users/myname/desktop/fceux/fceux.exe"); However, what i want to do is keep fceux/fceux.exe within the games files itself, that way when I build it, everything comes with the game (in this case, my application).
From what I read online, i would need to keep fceux/fceux.exe in the same directory as the launcher, however with Unity 5 I can't seem to find where that's at in my project folder. Where do I need to put the folder?
Can't you just put the fceux directory inside the directory that contains your executable (or your project root in editor), then just run it as a relative path?
System.Diagnostics.Process.Start("./fceux/fceux.exe");
On windows you might want to try ".\\fceux\\fceux.exe"
Answer by zach-r-d · Jul 01, 2015 at 10:55 AM
Put the file in a folder called StreamingAssets. The file will then be included in the data files that come along with the launcher. The path of the executable at runtime can be determined like so:
string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, "fceux.exe");
I added it to the games files, and my files go: game -> Assets, Library, ProjectSettings, Strea$$anonymous$$gAssets, Temp, etc. and then from there Strea$$anonymous$$gAssets -> fceux -> fceux.exe, other misc. files related to fceux
yet i still get the error that it can't find it? Here's the code i'm using:
public void PlayGame() {
string filePath = System.IO.Path.Combine(Application.strea$$anonymous$$gAssetsPath, "/fceux/fceux.exe");
System.Diagnostics.Process.Start(filePath);
}
Oh, the documentation doesn't make this totally clear, but Strea$$anonymous$$gAssets should be inside the Assets folder. You'll know it's working properly if any assets placed inside of it are not imported by Unity (e.g. an image file is just treated like a file rather than a texture).
see, i thought about that and put it in the Assets as well, and it still didn't work.
Can you confirm that dragging an image file into the Strea$$anonymous$$gAssets folder is not imported? When you say it "still didn't work", is there an error? Does nothing happen?
Your answer
Follow this Question
Related Questions
run external program within unity is possible? 0 Answers
Script Editor Highlighting? 1 Answer
open and close a door with a keypress 6 Answers
How do I simply re-open and edit a half-made script? 1 Answer
How can I compare directions of objects 2 Answers