質問編集履歴
1
ソースコードの追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,4 +4,85 @@
|
|
4
4
|
|
5
5
|
英語(半角文字)はちゃんと出力されます。
|
6
6
|
|
7
|
-
やりたいことは、pythonの日本語出力をunity上のコンソールで正しく表示することです。知恵をお貸しください。お願いします。
|
7
|
+
やりたいことは、pythonの日本語出力をunity上のコンソールで正しく表示することです。知恵をお貸しください。お願いします。
|
8
|
+
|
9
|
+
|
10
|
+
すみません。追記のソースコードです。
|
11
|
+
```ここに言語を入力
|
12
|
+
python
|
13
|
+
|
14
|
+
import sys
|
15
|
+
playerSelect=str(sys.argv[1])
|
16
|
+
print( "REPLY[" + playerSelect + "]:" + "日本語" )
|
17
|
+
|
18
|
+
```
|
19
|
+
|
20
|
+
```ここに言語を入力
|
21
|
+
C#
|
22
|
+
|
23
|
+
using System.Collections;
|
24
|
+
using System.Collections.Generic;
|
25
|
+
using UnityEngine;
|
26
|
+
using System.IO;
|
27
|
+
using System.Diagnostics;
|
28
|
+
|
29
|
+
public class PythonGo : MonoBehaviour
|
30
|
+
{
|
31
|
+
//pythonの場所
|
32
|
+
private string pyExePath = @"C:\Users\81909\AppData\Local\Programs\Python\Python37\python.exe";
|
33
|
+
|
34
|
+
//実行したいスクリプトがある場所
|
35
|
+
private string pyCodePath = @"C:\Users\81909\Desktop\MeCab\MeCabPython\otameshi.py";
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
// Start is called before the first frame update
|
40
|
+
private void Start()
|
41
|
+
{
|
42
|
+
//外部プロセス設定
|
43
|
+
ProcessStartInfo processStartInfo = new ProcessStartInfo() {
|
44
|
+
|
45
|
+
//実行するpythonファイル
|
46
|
+
FileName = pyExePath,
|
47
|
+
|
48
|
+
//WorkingDirectory = @cd,
|
49
|
+
|
50
|
+
//シェルを使うかどうか
|
51
|
+
UseShellExecute = false,
|
52
|
+
|
53
|
+
//ウィンドゥを開くかどうか
|
54
|
+
CreateNoWindow = true,
|
55
|
+
|
56
|
+
//テキスト出力をStandardOutputストリームに書き込むかどうか
|
57
|
+
RedirectStandardOutput = true,
|
58
|
+
|
59
|
+
//実行スクリプト 引数(複数可能)
|
60
|
+
Arguments = pyCodePath + " " + "\"日本語\""
|
61
|
+
|
62
|
+
};
|
63
|
+
|
64
|
+
//外部プロセス開始
|
65
|
+
Process process = Process.Start(processStartInfo);
|
66
|
+
|
67
|
+
//ストリームからの出力を得る
|
68
|
+
StreamReader streamReader = process.StandardOutput;
|
69
|
+
string str = streamReader.ReadLine();
|
70
|
+
|
71
|
+
//外部プロセス終了
|
72
|
+
process.WaitForExit();
|
73
|
+
process.Close();
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
//実行
|
80
|
+
print(str);
|
81
|
+
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
|
86
|
+
}
|
87
|
+
|
88
|
+
```
|