回答編集履歴
7
test
CHANGED
@@ -24,23 +24,23 @@
|
|
24
24
|
|
25
25
|
public const string CHOOSE_FILE =
|
26
26
|
|
27
|
-
"-e 'POSIX path of (get choose file of application "System Events" activate)'";
|
27
|
+
"-e 'POSIX path of (get choose file of application \"System Events\" activate)'";
|
28
28
|
|
29
29
|
public const string CHOOSE_FOLDER =
|
30
30
|
|
31
|
-
"-e 'POSIX path of (get choose folder of application "System Events" activate)'";
|
31
|
+
"-e 'POSIX path of (get choose folder of application \"System Events\" activate)'";
|
32
32
|
|
33
33
|
public const string CHOOSE_NEW_FILE =
|
34
34
|
|
35
|
-
"-e 'POSIX path of (get choose file name of application "System Events" activate)'";
|
35
|
+
"-e 'POSIX path of (get choose file name of application \"System Events\" activate)'";
|
36
36
|
|
37
37
|
public const string SIMPLE_DIALOG =
|
38
38
|
|
39
|
-
"-e 'tell application "System Events"nactivatendisplay dialog "clean" buttons {"OK"}nend tell'";
|
39
|
+
"-e 'tell application \"System Events\"\nactivate\ndisplay dialog \"clean\" buttons {\"OK\"}\nend tell'";
|
40
40
|
|
41
41
|
public const string FORCE_ACTIVATE =
|
42
42
|
|
43
|
-
"-e 'tell application "System Events" to activate'";
|
43
|
+
"-e 'tell application \"System Events\" to activate'";
|
44
44
|
|
45
45
|
|
46
46
|
|
6
hoge
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
```lang-c
|
9
|
+
```lang-csharp
|
10
10
|
|
11
11
|
using UnityEngine;
|
12
12
|
|
@@ -24,23 +24,23 @@
|
|
24
24
|
|
25
25
|
public const string CHOOSE_FILE =
|
26
26
|
|
27
|
-
"-e 'POSIX path of (get choose file of application
|
27
|
+
"-e 'POSIX path of (get choose file of application "System Events" activate)'";
|
28
28
|
|
29
29
|
public const string CHOOSE_FOLDER =
|
30
30
|
|
31
|
-
"-e 'POSIX path of (get choose folder of application
|
31
|
+
"-e 'POSIX path of (get choose folder of application "System Events" activate)'";
|
32
32
|
|
33
33
|
public const string CHOOSE_NEW_FILE =
|
34
34
|
|
35
|
-
"-e 'POSIX path of (get choose file name of application
|
35
|
+
"-e 'POSIX path of (get choose file name of application "System Events" activate)'";
|
36
36
|
|
37
37
|
public const string SIMPLE_DIALOG =
|
38
38
|
|
39
|
-
"-e 'tell application
|
39
|
+
"-e 'tell application "System Events"nactivatendisplay dialog "clean" buttons {"OK"}nend tell'";
|
40
40
|
|
41
41
|
public const string FORCE_ACTIVATE =
|
42
42
|
|
43
|
-
"-e 'tell application
|
43
|
+
"-e 'tell application "System Events" to activate'";
|
44
44
|
|
45
45
|
|
46
46
|
|
5
えすけーぷ?
test
CHANGED
File without changes
|
4
えすけーぷ
test
CHANGED
File without changes
|
3
lang追加
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
```
|
9
|
+
```lang-c#
|
10
10
|
|
11
11
|
using UnityEngine;
|
12
12
|
|
2
FORCE_ACTIVATEを実装
test
CHANGED
@@ -22,111 +22,117 @@
|
|
22
22
|
|
23
23
|
{
|
24
24
|
|
25
|
-
|
25
|
+
public const string CHOOSE_FILE =
|
26
26
|
|
27
|
-
|
27
|
+
"-e 'POSIX path of (get choose file of application \"System Events\" activate)'";
|
28
28
|
|
29
|
-
|
29
|
+
public const string CHOOSE_FOLDER =
|
30
30
|
|
31
|
-
|
31
|
+
"-e 'POSIX path of (get choose folder of application \"System Events\" activate)'";
|
32
32
|
|
33
|
-
|
33
|
+
public const string CHOOSE_NEW_FILE =
|
34
34
|
|
35
|
-
|
35
|
+
"-e 'POSIX path of (get choose file name of application \"System Events\" activate)'";
|
36
36
|
|
37
|
-
|
37
|
+
public const string SIMPLE_DIALOG =
|
38
38
|
|
39
|
-
|
39
|
+
"-e 'tell application \"System Events\"\nactivate\ndisplay dialog \"clean\" buttons {\"OK\"}\nend tell'";
|
40
|
+
|
41
|
+
public const string FORCE_ACTIVATE =
|
42
|
+
|
43
|
+
"-e 'tell application \"System Events\" to activate'";
|
40
44
|
|
41
45
|
|
42
46
|
|
43
|
-
|
47
|
+
void Start()
|
44
48
|
|
45
|
-
|
49
|
+
{
|
46
50
|
|
47
|
-
|
51
|
+
StartCoroutine (FileChooseDialog (CHOOSE_FILE, (string path) => {
|
48
52
|
|
49
|
-
|
53
|
+
UnityEngine.Debug.Log ("this is " + path);
|
50
54
|
|
51
|
-
|
55
|
+
}));
|
52
56
|
|
53
|
-
|
57
|
+
}
|
54
58
|
|
55
59
|
|
56
60
|
|
57
|
-
|
61
|
+
/// <summary>
|
58
62
|
|
59
|
-
|
63
|
+
/// osascript -e 'tell application "System Events" to POSIX path of (active choose file)'
|
60
64
|
|
61
|
-
|
65
|
+
/// or
|
62
66
|
|
63
|
-
|
67
|
+
/// osascript -e 'POSIX path of (get choose file of application "System Events" activate)'
|
64
68
|
|
65
|
-
|
69
|
+
/// </summary>
|
66
70
|
|
67
|
-
|
71
|
+
/// <returns>The choose dialog.</returns>
|
68
72
|
|
69
|
-
|
73
|
+
public IEnumerator FileChooseDialog (string chooseType, System.Action<string> onClosed)
|
70
74
|
|
71
|
-
|
75
|
+
{
|
72
76
|
|
73
|
-
|
77
|
+
Process fileDialog = new Process ();
|
74
78
|
|
75
|
-
|
79
|
+
fileDialog.StartInfo = new ProcessStartInfo ()
|
76
80
|
|
77
|
-
|
81
|
+
{
|
78
82
|
|
79
|
-
|
83
|
+
FileName = "osascript",
|
80
84
|
|
81
|
-
|
85
|
+
Arguments = chooseType,
|
82
86
|
|
83
|
-
|
87
|
+
CreateNoWindow = true,
|
84
88
|
|
85
|
-
|
89
|
+
UseShellExecute = false,
|
86
90
|
|
87
|
-
|
91
|
+
RedirectStandardOutput = true,
|
88
92
|
|
89
|
-
|
93
|
+
RedirectStandardError = true,
|
90
94
|
|
91
|
-
|
95
|
+
};
|
92
96
|
|
93
|
-
|
97
|
+
StringBuilder result = new StringBuilder ();
|
94
98
|
|
95
|
-
|
99
|
+
fileDialog.OutputDataReceived += (object sender, DataReceivedEventArgs e) => {
|
96
100
|
|
97
|
-
|
101
|
+
result.Append (e.Data);
|
98
102
|
|
99
|
-
|
103
|
+
};
|
100
104
|
|
101
|
-
|
105
|
+
fileDialog.ErrorDataReceived += (object sender, DataReceivedEventArgs e) => {
|
102
106
|
|
103
|
-
|
107
|
+
UnityEngine.Debug.LogError (e.Data);
|
104
108
|
|
105
|
-
|
109
|
+
};
|
106
110
|
|
107
|
-
|
111
|
+
fileDialog.Start ();
|
108
112
|
|
109
|
-
|
113
|
+
fileDialog.BeginOutputReadLine ();
|
110
114
|
|
111
|
-
|
115
|
+
fileDialog.BeginErrorReadLine ();
|
112
116
|
|
113
|
-
|
117
|
+
yield return null;
|
114
118
|
|
115
|
-
|
119
|
+
Process.Start (new ProcessStartInfo () { FileName = "osascript", Arguments = FORCE_ACTIVATE });
|
116
120
|
|
117
|
-
|
121
|
+
while (fileDialog.HasExited == false) {
|
118
122
|
|
119
|
-
|
123
|
+
yield return null;
|
120
124
|
|
121
|
-
|
125
|
+
}
|
122
126
|
|
123
|
-
|
127
|
+
fileDialog.Close ();
|
124
128
|
|
129
|
+
fileDialog.Dispose ();
|
130
|
+
|
131
|
+
onClosed.Invoke (result.ToString ());
|
132
|
+
|
125
|
-
|
133
|
+
}
|
126
134
|
|
127
135
|
}
|
128
|
-
|
129
|
-
|
130
136
|
|
131
137
|
```
|
132
138
|
|
1
コード微修正
test
CHANGED
@@ -70,7 +70,9 @@
|
|
70
70
|
|
71
71
|
{
|
72
72
|
|
73
|
+
Process fileDialog = new Process ();
|
74
|
+
|
73
|
-
|
75
|
+
fileDialog.StartInfo = new ProcessStartInfo ()
|
74
76
|
|
75
77
|
{
|
76
78
|
|
@@ -87,10 +89,6 @@
|
|
87
89
|
RedirectStandardError = true,
|
88
90
|
|
89
91
|
};
|
90
|
-
|
91
|
-
Process fileDialog = new Process ();
|
92
|
-
|
93
|
-
fileDialog.StartInfo = psi;
|
94
92
|
|
95
93
|
StringBuilder result = new StringBuilder ();
|
96
94
|
|