You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Unity 2017.3.0f3集成VSCode后多工作区及参数设置缺失问题求助

Fixing VSCode-Unity 2017.3.0f3 Integration Issues

Hey there, let’s work through these three common integration headaches with Unity 2017.3.0f3 and VSCode—they’re totally solvable with a few tweaks:

1. Stop Multiple VSCode Workspaces From Opening

The root issue here is how Unity sends files to VSCode by default: it launches a new instance for each script instead of reusing an existing window/workspace. Here’s how to fix it:

  • First, make sure VSCode is set as your default external script editor in Unity: go to Edit > Preferences > External Tools, then select Visual Studio Code from the External Script Editor dropdown (if it’s not listed, use Browse to locate your Code.exe/Code executable).
  • Once VSCode is selected, you should see an External Script Editor Args field pop up (we’ll tackle the "missing args field" issue next if it doesn’t appear). In this field, paste:
    -r -g "$(File):$(Line)"
    
    The -r flag tells VSCode to reuse the last active window, and -g "$(File):$(Line)" jumps straight to the correct line in the file.
  • If you still see multiple workspaces, manually open your Unity project’s root folder in VSCode first (File > Open Folder). This establishes a single workspace, so any subsequent script launches from Unity will open in that same window.

2. Prevent Workspace Count From Increasing After "Open C# Project"

This is directly tied to the parameter issue above. Once you’ve set the -r argument in the external editor settings, clicking Assets > Open C# Project will generate the necessary .vscode folder (with settings.json and launch.json) and open the project in a single VSCode window. After that, double-clicking scripts in Unity will no longer spawn new workspaces—they’ll open in the existing window.

3. Fix Missing "External Script Editor Args" Setting

If the args field doesn’t show up after selecting VSCode as your external editor, try these workarounds:

  • Restart Unity: Sometimes the UI doesn’t refresh correctly after selecting a new editor. Close and reopen Unity, then check the External Tools tab again.
  • Use a wrapper script (Windows/Mac): Create a simple script to act as a middleman between Unity and VSCode, which will pass the correct arguments automatically:
    • For Windows: Create a .bat file (e.g., VSCodeUnityLauncher.bat) with this code:
      @echo off
      code -r -g "%1:%2"
      
      Save it somewhere accessible, then in Unity’s External Script Editor, select this .bat file instead of directly selecting Code.exe.
    • For Mac: Create a .sh script (e.g., VSCodeUnityLauncher.sh) with this code:
      #!/bin/bash
      code -r -g "$1:$2"
      
      Make it executable (run chmod +x VSCodeUnityLauncher.sh in Terminal), then select it in Unity’s external editor settings.
  • Edit Unity’s preferences file manually:
    • On Windows: Navigate to C:\Users\[YourUsername]\AppData\Roaming\Unity\EditorPreferences.asset (use VSCode or another YAML-compatible editor to open it). Find the section for external editor settings and add the args parameter with -r -g "$(File):$(Line)".
    • On Mac: Go to ~/Library/Preferences/com.unity3d.UnityEditor2017.x.plist (replace x with your exact Unity version), then add the args string to the external editor entry. Use a plist editor if you don’t want to edit it manually.

All these steps should resolve your workspace duplication and missing settings issues. Let me know if you hit any snags!

内容的提问来源于stack exchange,提问作者Diptangshu Chakrabarty

火山引擎 最新活动