-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-script.js
More file actions
48 lines (38 loc) · 1.13 KB
/
Copy pathdebug-script.js
File metadata and controls
48 lines (38 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import net from 'net';
import { promises as fs } from 'fs';
import path from 'path';
import os from 'os';
const PIPE_NAME = 'vibelink_unity_pipe';
function getPipePath() {
if (process.platform === 'win32') {
return `\\\\.\\pipe\\${PIPE_NAME}`;
} else {
return path.join(os.tmpdir(), `CoreFxPipe_${PIPE_NAME}`);
}
}
async function runDebugScript() {
const pipePath = getPipePath();
console.log(`[Debug] Connecting to: ${pipePath}`);
const socket = net.createConnection(pipePath);
socket.on('connect', () => {
console.log('[Debug] Connected!');
// Command to get DataPath
const msg = {
id: 'debug_' + Date.now(),
type: 'request',
command: 'unity_execute_script',
payload: JSON.stringify({
code: 'Application.dataPath'
}),
timestamp: Date.now()
};
console.log('[Debug] Sending:', JSON.stringify(msg));
socket.write(JSON.stringify(msg) + '\n');
});
socket.on('data', (data) => {
console.log('[Debug] Received:', data.toString());
socket.end();
});
socket.on('error', (err) => console.error('[Debug] Error:', err));
}
runDebugScript();