How to run or remote external program within Unity Editor ?

Hi all,

I am looking for the way to use Unity as a pre-production tool. Is there anyway to run external program within unity editor ?

This is my case, I wrote a script for readout the hierarchy of the GameObject and saved as a text file onto the local hard disk, then open it by an Apple OSX program called Graphviz for making hierarchy chart.

(Currentlly, I open it manually)

Is there any command can boot up that application and pass in the text file onto the target program within Unity ?? If yes, I like to create more tool, like linking to imagemagick… etc

Many Thanks,

From the editor yes through the .net functionality for that (see MSDN, docs for the System namespace), but not within as part of it.

Although I can’t found anything from MSDN (as usual), but thank you so much for telling me the right direction :slight_smile:

I found this somewhere and its seem to work for me :slight_smile:

import System.Diagnostics;

var path:String = "somewhere";
var foo:Process = new Process();
function Start() 
{	
	foo.StartInfo.FileName = "someprogram";
	foo.StartInfo.Arguments = path;
	foo.Start();
}
import System.Diagnostics;

var path:String = "somewhere";
var foo:Process = new Process();
function Start() 
{	
	foo.StartInfo.FileName = "someprogram";
	foo.StartInfo.Arguments = path;
	foo.Start();
}

Um, Hi, I’m really new to unity and I’m interested in running external programs as well… and how… do I use this exactly?

Not sure yet, since I am using Mac. The method does not work for me :frowning:

Well, the above code is from here originally…
http://answers.unity3d.com/questions/9420/running-an-external-exe-file-from-unity
Maybe work for windows user :slight_smile:

Good Luck !

here’s another way:

http://www.unifycommunity.com/wiki/index.php?title=OpenVisualStudioProject

System.Diagnostics.Process.Start() is one to look up

Many Thanks ! It is work on OSX now !!

import System.IO;

function Start()
{
	var info:FileInfo = new FileInfo("/Applications/TextEdit.app/Contents/MacOS/TextEdit");
	System.Diagnostics.Process.Start(info.FullName);
}
import System.Diagnostics;


var fileLocation: String = "C:/Program Files/Skype/Phone/Skype.exe";
var test:Process = new Process();
test.StartInfo.FileName = fileLocation;
function Start()
{

test.Start();
UnityEngine.Debug.Log("we got here!");
}

This one works (for windows), too But I have some question here - when I build it into web player version, it doesn’t work anymore. Can anyone come up with this idea?

1 Like

Never works ! It is the security reason. The web-player can’t access the local IO. In fact, that is very danger, if allowed. I may remote any computer in this planet to do something… :stuck_out_tongue:

The webplayer can not access anything related to the local system:

No system.io.file stuff, no file:// protocol, no System.Environment, no System.Diagnostics

You can communicate to the outer world only through requestes to the web and that will be done through the browsers networking

Lol, I’m necroposting again, but would this work in a Windows Standalone? It might be just what I need.

Dw, sorted. IT’S PERFECT!

Now with some money, my game console can go ahead, and all because of this line of code :smile:

Wow this is amazing. I can load macro files from autohotkey (compiled to .exe) with Unity…allowing imagesearch(), pixelsearch() functions, controlling the mouse position and simulating inputs, along with dialogue/tooltips independent of Unity that overlay the game window. Probably useful for simulators. Or instructional GUI’s…

When you load unity it loads the script, when the script loads it checks for the unity window and focuses on it. You can scan for pixels or images, move the mouse to it, send various input from the keyboard/mouse or custom scripts even tie into mysql etc.

Hi,

I did make this work on OSX but it doesn’t want to work if I want to open the Terminal. Does it requires another extension name such as .app ? If you have any idea please tell me :slight_smile: Thanks a lot!

I am trying to start a process in Linux using below c# code in mono developer for Unity in start function.

Process.start(filepath);

Results as checked in task manager of linux

  1. Process starts but ends in 3 secs with Memory shown as ‘N/A’ in task manager during the 3 secs and Status as ‘Zombie’

Note : The process works fine when executed from terminal or when double clicked or when run in Unity independent C# project

Hey there! Did you ever get this to work and open a Terminal window? I’ve run into the same issue. It works behind the scenes, but I don’t know its progress etc.

I got it working with:

ProcessStartInfo startInfo = new ProcessStartInfo() {
                FileName = "bash",
                UseShellExecute = false,
                RedirectStandardError = true,
                RedirectStandardInput = true,
                RedirectStandardOutput = true,
                CreateNoWindow = true,
                Arguments = " -c \"" + command + " \""
            };
1 Like

You my friend have solved my week long head ache trying to lauch VS Code on mac through my editor tools

Is there a way to do this during play mode? My thread keeps getting aborted, likely by Unity.

1 Like