Skip to content

Instantly share code, notes, and snippets.

@arakaki-asdf
Created February 20, 2024 10:05
Show Gist options
  • Save arakaki-asdf/7c1a753693313a21cdbf4531f9fb8551 to your computer and use it in GitHub Desktop.
Save arakaki-asdf/7c1a753693313a21cdbf4531f9fb8551 to your computer and use it in GitHub Desktop.
UnityでGit RepositryをVS Codeを開く
using System.Diagnostics;
using UnityEditor;
using UnityEngine;
public class OpenVSCode
{
[MenuItem("Window/Open VS Code Git Repository")]
static void OpenVSCodeGitRepository()
{
var repositoryPath = Execute("git", "rev-parse --show-toplevel");
Execute("cmd", $"/C code {repositoryPath}");
}
static string Execute(string exe, string parameter)
{
using (var process = new Process())
{
process.StartInfo = new ProcessStartInfo(exe, parameter)
{
UseShellExecute = false,
WorkingDirectory = Application.dataPath,
RedirectStandardInput = true,
RedirectStandardOutput = true,
CreateNoWindow = true,
};
process.Start();
return process.StandardOutput.ReadToEnd();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment