using System; using System.Diagnostics; using System.IO; using UnityEngine; public class RunExe : MonoBehaviour { public static void StartExe(string filePath) { // 构建exe文件的完整路径 string exePath = Path.Combine(filePath); // 替换为你的exe文件名 // 检查exe文件是否存在 if (!File.Exists(exePath)) { UnityEngine.Debug.LogError("exe文件不存在: " + exePath); return; } try { // 使用Process启动exe文件 ProcessStartInfo startInfo = new ProcessStartInfo { FileName = exePath, UseShellExecute = true, CreateNoWindow = false }; Process process = new Process { StartInfo = startInfo }; process.Start(); UnityEngine.Debug.Log("exe文件已启动: " + exePath); } catch (Exception ex) { UnityEngine.Debug.LogError("启动exe文件时出错: " + ex.Message); } } }
标签:文件,UnityEngine,exe,System,Unity,调用,using,exePath From: https://www.cnblogs.com/zqiang0803/p/18513234