#!/usr/bin/env bash # Installs Unity's MIT-licensed vscode-unity-debug adapter for nvim-dap and # patches it to find editors however they were launched (see patch.cs). # Re-runnable: always re-extracts and re-patches from the pristine .vsix. set -euo pipefail VERSION=3.0.1 HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" DEST="${1:-${XDG_DATA_HOME:-$HOME/.local/share}/nvim/unity-debug}" BIN="$DEST/extension/bin" for cmd in curl unzip mono mcs; do command -v "$cmd" >/dev/null || { echo "unity-debug install: missing '$cmd'" >&2; exit 1; } done mkdir -p "$DEST" VSIX="$DEST/unity-debug-$VERSION.vsix" [ -f "$VSIX" ] || curl -fsSL -o "$VSIX" \ "https://github.com/Unity-Technologies/vscode-unity-debug/releases/download/Version-$VERSION/unity-debug-$VERSION.vsix" rm -rf "$DEST/extension" unzip -qo "$VSIX" -d "$DEST" TMP="$(mktemp -d)" trap 'rm -rf "$TMP"' EXIT mcs "$HERE/patch.cs" -r:"$BIN/Mono.Cecil.dll" -out:"$TMP/patch.exe" cp "$BIN/UnityDebug.exe" "$BIN/UnityDebug.exe.orig" MONO_PATH="$BIN" mono "$TMP/patch.exe" "$BIN/UnityDebug.exe.orig" "$TMP/UnityDebug.exe" cp "$TMP/UnityDebug.exe" "$BIN/UnityDebug.exe" echo "unity-debug installed and patched in $DEST"