Skip to content

Commit

Permalink
feat: first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sonic853 committed Nov 8, 2022
0 parents commit 5481c86
Show file tree
Hide file tree
Showing 32 changed files with 1,057 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Mm]emoryCaptures/

# Asset meta data should only be ignored when the corresponding asset is also ignored
!/[Aa]ssets/**/*.meta

# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*

# Autogenerated Jetbrains Rider plugin
[Aa]ssets/Plugins/Editor/JetBrains*

# Visual Studio cache directory
.vs/

# Gradle cache directory
.gradle/

# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db

# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta

# Unity3D generated file on crash reports
sysinfo.txt

# Builds
*.apk
*.unitypackage

# Crashlytics generated file
crashlytics-build.properties

8 changes: 8 additions & 0 deletions Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions Editor/DragLine.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using UnityEngine.UIElements;

namespace Sonic853.UpmGithubManager
{
class DragLine
{
public static VisualElement CreateDragLine(VisualElement obj, SquareResizer.Direction direction = SquareResizer.Direction.Horizontal, SquareResizer.PanelFloat panelfloat = SquareResizer.PanelFloat.Left, float minSize = 100)
{
// dragLineAnchor
VisualElement dragLineAnchor = new VisualElement();
dragLineAnchor.name = "unity-debugger-splitter-dragline-anchor";
dragLineAnchor.AddToClassList(direction == SquareResizer.Direction.Horizontal ? "horizontal" : "vertical");
// dragLine
VisualElement dragLine = new VisualElement();
dragLine.name = "unity-debugger-splitter-dragline";
dragLine.AddManipulator(new SquareResizer(obj, direction, panelfloat, minSize));
dragLineAnchor.Add(dragLine);
return dragLineAnchor;
}
}
}
11 changes: 11 additions & 0 deletions Editor/DragLine.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 90 additions & 0 deletions Editor/GithubAPI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using System.Threading.Tasks;
using Newtonsoft.Json;
using UnityEngine;
using UnityEngine.Networking;

namespace Sonic853.UpmGithubManager
{
class GithubAPI
{
/// <summary>
/// 查询用的 Token,如果不填写,每小时只能查询 60 次
/// </summary>
public static string Token;
/// <summary>
/// 获取所有 Tag
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public static async Task<string[]> GetTags(string url)
{
// url = https://github.com/Username/Repo.git
// 从 url 获取 Username/Repo,去掉 .git
string[] urlSplit = url.Split('/');
string repo = urlSplit[urlSplit.Length - 1];
if (repo.EndsWith(".git"))
{
repo = repo.Substring(0, repo.Length - 4);
}
string username = urlSplit[urlSplit.Length - 2];
// https://api.github.com/repos/Username/Repo/tags
string apiUrl = "https://api.github.com/repos/" + username + "/" + repo + "/tags";
UnityWebRequest www = UnityWebRequest.Get(apiUrl);
if (Token != null)
{
www.SetRequestHeader("Authorization", "Bearer " + Token);
}
await www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
Debug.LogError(www.error);
return new string[0];
}
else
{
var _result = JsonConvert.DeserializeObject<GithubAPITag[]>(www.downloadHandler.text);
string[] tags = new string[_result.Length];
for (int i = 0; i < _result.Length; i++)
{
tags[i] = _result[i].name;
}
return tags;
}
}
public static async Task<string[]> GetBranches(string url)
{
// url = https://github.com/Username/Repo.git
// 从 url 获取 Username/Repo,去掉 .git
string[] urlSplit = url.Split('/');
string repo = urlSplit[urlSplit.Length - 1];
if (repo.EndsWith(".git"))
{
repo = repo.Substring(0, repo.Length - 4);
}
string username = urlSplit[urlSplit.Length - 2];
// https://api.github.com/repos/Username/Repo/branches
string apiUrl = "https://api.github.com/repos/" + username + "/" + repo + "/branches";
UnityWebRequest www = UnityWebRequest.Get(apiUrl);
if (Token != null)
{
www.SetRequestHeader("Authorization", "Bearer " + Token);
}
await www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
Debug.LogError(www.error);
return new string[0];
}
else
{
var _result = JsonConvert.DeserializeObject<GithubAPIBranche[]>(www.downloadHandler.text);
string[] branches = new string[_result.Length];
for (int i = 0; i < _result.Length; i++)
{
branches[i] = _result[i].name;
}
return branches;
}
}
}
}
11 changes: 11 additions & 0 deletions Editor/GithubAPI.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Editor/GithubAPIBranche.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Sonic853.UpmGithubManager
{
class GithubAPIBranche
{
public string name;
public GithubAPICommit commit;
}
}
11 changes: 11 additions & 0 deletions Editor/GithubAPIBranche.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Editor/GithubAPICommit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Sonic853.UpmGithubManager
{
class GithubAPICommit
{
public string sha;
public string url;
}
}
11 changes: 11 additions & 0 deletions Editor/GithubAPICommit.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Editor/GithubAPITag.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Sonic853.UpmGithubManager
{
class GithubAPITag
{
public string name;
public string zipball_url;
public string tarball_url;
public GithubAPICommit commit;
public string node_id;
}
}
11 changes: 11 additions & 0 deletions Editor/GithubAPITag.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 82 additions & 0 deletions Editor/GithubItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using System.Collections.Generic;

namespace Sonic853.UpmGithubManager
{
class GithubItem
{
/// <summary>
/// 包名
/// </summary>
public string name;
string _url;
/// <summary>
/// URL
/// </summary>
// url = https://github.com/Username/Repo.git?path=/Packages/com.your.package#6.6.6
public string url
{
get
{
return _url + "?path=" + path + (version == "#latest#" ? "" : ("#" + version));
}
set
{
oldUrl = value;
string[] urlSplit = value.Split('#');
if (urlSplit.Length > 1)
{
version = urlSplit[1];
}
else
{
version = "#latest#";
}
// args
string[] argsSplit = urlSplit[0].Split('?');
args.Clear();
path = "";
_url = argsSplit[0];
if (argsSplit.Length > 1)
{
string[] argList = argsSplit[1].Split('&');
foreach (string arg in argList)
{
string[] argSplit = arg.Split('=');
if (argSplit.Length > 1)
{
args.Add(argSplit[0], argSplit[1]);
if (argSplit[0] == "path")
{
path = argSplit[1];
}
}
else
{
args.Add(argSplit[0], "");
}
}
}
}
}
public string sourceUrl
{
get
{
return _url;
}
}
public string oldUrl;
public bool customVersion;
public string version;
public string[] tags;
public string[] branches;
/// <summary>
/// 参数
/// </summary>
Dictionary<string, string> args = new Dictionary<string, string>();
/// <summary>
/// 路径
/// </summary>
public string path;
}
}
11 changes: 11 additions & 0 deletions Editor/GithubItem.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5481c86

Please sign in to comment.