我试着运行一个来自unity的python脚本(C#script)来使用它的输出,这是一个文本文件,稍后在我的游戏中,问题是当我在unity中运行C#脚本时,什么也不会发生(python脚本本身工作得很好)。有人能告诉我我缺了什么吗?
谢谢。using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.IO;
using UnityEngine.UI;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Runtime.InteropServices;
public class PyCx : MonoBehaviour {
public Text Message;
public GameObject OpenPanel1 = null;
// Use this for initialization
void Start () {
python ();
read ();
ShowMessage ();
}
public void python(){
ProcessStartInfo pythonInfo = new ProcessStartInfo ();
Process python;
pythonInfo.FileName=@"C:\Users\HP\AppData\Local\Programs\Python\Python36-32\python.exe";
pythonInfo.Arguments=@"C:\Users\HP\Documents\projet1.pyw";
pythonInfo.CreateNoWindow = false;
pythonInfo.UseShellExecute = false;
python = Process.Start (pythonInfo);
python.WaitForExit ();
python.Close ();
}
public void read(){
using (var reader = new StreamReader ("C://Users//HP//Documents//result.txt")) {
string line = reader.ReadToEnd ();
Message.text = (line);
}
}
public void ShowMessage(){
OpenPanel1.SetActive (true);
Message.IsActive ();
}
// Update is called once per frame
void Update () {
}
}