diff --git a/package.json b/package.json index 12ccccc0..16d1b179 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "build-electron-arm64": "node ./src-electron/download-dotnet-runtime.js --arch=arm64 && node ./src-electron/patch-package-version.js && electron-builder --arm64 --publish never", "postbuild-electron": "node ./src-electron/patch-node-api-dotnet.js --arch=x64 && node ./src-electron/rename-builds.js --arch=x64", "postbuild-electron-arm64": "node ./src-electron/patch-node-api-dotnet.js --arch=arm64 && node ./src-electron/rename-builds.js --arch=arm64", - "start-electron": "electron ." + "start-electron": "electron . --hot-reload" }, "repository": { "type": "git", diff --git a/src-electron/main.js b/src-electron/main.js index c1b0ab8c..b36b1e4b 100644 --- a/src-electron/main.js +++ b/src-electron/main.js @@ -56,6 +56,7 @@ const noInstall = args.includes('--no-install'); const x11 = args.includes('--x11'); const noDesktop = args.includes('--no-desktop'); const startup = args.includes('--startup'); +const debug = args.includes('--hot-reload'); const noUpdater = args.includes('--no-updater') || fs.existsSync(path.join(rootDir, '.no-updater')); @@ -327,6 +328,10 @@ function createWindow() { applyWindowState(); const indexPath = path.join(rootDir, 'build/html/index.html'); mainWindow.loadFile(indexPath); + if (debug) { + mainWindow.loadURL('http://localhost:9000/index.html'); + mainWindow.webContents.openDevTools(); + } // add proxy config, doesn't work, thanks electron // const proxy = VRCXStorage.Get('VRCX_Proxy'); @@ -436,7 +441,10 @@ function createWristOverlayWindowOffscreen() { }); wristOverlayWindow.webContents.setFrameRate(2); - const indexPath = path.join(rootDir, 'build/html/vr.html'); + let indexPath = path.join(rootDir, 'build/html/vr.html'); + if (debug) { + indexPath = 'http://localhost:9000/vr.html'; + } const fileUrl = `file://${indexPath}?wrist`; wristOverlayWindow.loadURL(fileUrl, { userAgent: version }); @@ -499,7 +507,10 @@ function createHmdOverlayWindowOffscreen() { }); hmdOverlayWindow.webContents.setFrameRate(48); - const indexPath = path.join(rootDir, 'build/html/vr.html'); + let indexPath = path.join(rootDir, 'build/html/vr.html'); + if (debug) { + indexPath = 'http://localhost:9000/vr.html'; + } const fileUrl = `file://${indexPath}?hmd`; hmdOverlayWindow.loadURL(fileUrl, { userAgent: version });