Unity3D C#打开外部应用程序,并检测应用程序是否关闭退出实现代码:
using UnityEngine;
using System.Collections;
using System.Diagnostics;
using System;
public class StartOtherApp : MonoBehaviour {
private Process pc;
void Start () {
StartCoroutine(StartApp());
}
IEnumerator StartApp()
{
yield return new WaitForSeconds(2);
pc = Process.Start(\"C:/Users/Lee/Desktop/Flash VideoPlayer/VRPlayer/VRPlayer.app/VRPlayer.exe\");
pc.EnableRaisingEvents = true;
pc.Exited += new EventHandler(myProcess_Exited);
}
void myProcess_Exited(object sender, EventArgs e)
{
Application.Quit();
}
}