Created
February 20, 2024 10:05
-
-
Save arakaki-asdf/7c1a753693313a21cdbf4531f9fb8551 to your computer and use it in GitHub Desktop.
UnityでGit RepositryをVS Codeを開く
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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