Skip to content

Instantly share code, notes, and snippets.

@p-chin
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save p-chin/4f84de96267d2a7fe1d8 to your computer and use it in GitHub Desktop.
Save p-chin/4f84de96267d2a7fe1d8 to your computer and use it in GitHub Desktop.
UnityのProjectWindowからAssetを選択して右クリックして出たメニューからgithubのページを開いてくれるEditorTool
using UnityEngine;
using UnityEditor;
public class GitHubPageJumper
{
// ref https://github.com/p-chin/dotfiles
private static readonly string gitHubTeamName = "p-chin";
private static readonly string gitHubRepositoryName = "dotfiles";
private static readonly string gitHubBranchName = "master";
[MenuItem("Assets/OpenGithubPage")]
public static void OpenGitHubPage() {
string targetPath = GetTargetPath();
var url = string.Format ("https://github.com/{0}/{1}/blob/{2}/{3}",
gitHubTeamName, gitHubRepositoryName, gitHubBranchName, targetPath);
Debug.Log("Open " + url);
Application.OpenURL (url);
}
private static string GetTargetPath()
{
Object selected = Selection.objects[0];
if (selected == null)
{
Debug.LogError ("Please select from the file ProjectWindow");
return null;
}
return AssetDatabase.GetAssetPath(selected);;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment