Skip to content

Commit

Permalink
1.3.1
Browse files Browse the repository at this point in the history
## [1.3.1](v1.3.0...v1.3.1) (2020-08-14)

### Bug Fixes

* Cannot implicitly convert type 'UnityEditor.PackageManager.UI.IPageManager' ([4122c94](4122c94)), closes [#93](#93)
* Package resolver is not working in Unity 2020.2 ([a3d6140](a3d6140))
* uninstall package from lock file ([ab696d8](ab696d8))
  • Loading branch information
semantic-release-bot committed Aug 14, 2020
1 parent f15792c commit ecf4c7d
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 73 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## [1.3.1](https://github.com/mob-sakai/UpmGitExtension/compare/v1.3.0...v1.3.1) (2020-08-14)


### Bug Fixes

* Cannot implicitly convert type 'UnityEditor.PackageManager.UI.IPageManager' ([4122c94](https://github.com/mob-sakai/UpmGitExtension/commit/4122c948e50c7fe45490574859e65a7604e31339)), closes [#93](https://github.com/mob-sakai/UpmGitExtension/issues/93)
* Package resolver is not working in Unity 2020.2 ([a3d6140](https://github.com/mob-sakai/UpmGitExtension/commit/a3d61400e1cb17074d3bbbbe780a392202661057))
* uninstall package from lock file ([ab696d8](https://github.com/mob-sakai/UpmGitExtension/commit/ab696d865abf48be48fa5a3725f29db0626d0a6d))

# [1.3.0](https://github.com/mob-sakai/UpmGitExtension/compare/v1.2.3...v1.3.0) (2020-08-13)


Expand Down
7 changes: 2 additions & 5 deletions Editor/Coffee.UpmGitExtension/AvailableVersionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,8 @@ static void WatchResultJson()
EnableRaisingEvents = true,
};

watcher.Created += (s, e) =>
{
EditorApplication.delayCall += () => OnResultCreated(e.FullPath);
};
watcher.Created += (s, e) => { EditorApplication.delayCall += () => OnResultCreated(e.FullPath); };
}
}
}
#endif // [ASMDEFEX] DO NOT REMOVE THIS LINE MANUALLY.
#endif // [ASMDEFEX] DO NOT REMOVE THIS LINE MANUALLY.
38 changes: 19 additions & 19 deletions Editor/Coffee.UpmGitExtension/AvailableVersions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,25 @@ public class AvailableVersion : IEquatable<AvailableVersion>
public string refName = "";
public string repoUrl = "";

public string refNameText { get { return version == refName ? version : version + " - " + refName; } }
public string refNameVersion { get { return version == refName ? version : version + "-" + refName; } }
public string refNameText => version == refName ? version : version + " - " + refName;

public string refNameVersion => version == refName ? version : version + "-" + refName;

bool IEquatable<AvailableVersion>.Equals(AvailableVersion other)
{
return other != null
&& packageName == other.packageName
&& version == other.version
&& repoUrl == other.repoUrl
&& refName == other.refName;
&& packageName == other.packageName
&& version == other.version
&& repoUrl == other.repoUrl
&& refName == other.refName;
}

public override int GetHashCode()
{
return packageName.GetHashCode()
+ version.GetHashCode()
+ repoUrl.GetHashCode()
+ refName.GetHashCode();
+ version.GetHashCode()
+ repoUrl.GetHashCode()
+ refName.GetHashCode();
}
}

Expand All @@ -49,7 +50,7 @@ public class AvailableVersions : ScriptableSingleton<AvailableVersions>
const string kPackageDir = "Library/UGE/packages";

public AvailableVersion[] versions = new AvailableVersion[0];

public static event Action OnChanged = () => { };

public static void ClearAll()
Expand Down Expand Up @@ -78,29 +79,28 @@ public static IEnumerable<AvailableVersion> GetVersions(string packageName = nul
public static void Dump()
{
var sb = new StringBuilder("[AvailableVersions] Dump:\n");
foreach(var v in instance.versions.OrderBy(x=>x.packageName).ThenBy(x=>x.version))
foreach (var v in instance.versions.OrderBy(x => x.packageName).ThenBy(x => x.version))
{
sb.AppendLine(JsonUtility.ToJson(v));
}

UnityEngine.Debug.Log(sb);
}

public static void AddVersions(IEnumerable<AvailableVersion> add)
{
if (add == null || !add.Any())
return;
if (add == null || !add.Any()) return;

var length = instance.versions.Length;
var versions = instance.versions
.Union(add)
.ToArray();

if (versions.Length != length)
{
instance.versions = versions;
OnChanged();
}
if (versions.Length == length) return;

instance.versions = versions;
OnChanged();
}
}
}
#endif // [ASMDEFEX] DO NOT REMOVE THIS LINE MANUALLY.
#endif // [ASMDEFEX] DO NOT REMOVE THIS LINE MANUALLY.
23 changes: 15 additions & 8 deletions Editor/Coffee.UpmGitExtension/InternalBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#endif
#if UNITY_2020_1_OR_NEWER
using UnityEditor.Scripting.ScriptCompilation;

#endif

namespace Coffee.UpmGitExtension
Expand All @@ -35,14 +36,20 @@ internal class Bridge
const string kHeader = "<b><color=#c7634c>[Bridge]</color></b> ";

private static Bridge instance = new Bridge();
public static Bridge Instance { get { return instance; } }

public static Bridge Instance
{
get { return instance; }
}

PackageList packageList;
PackageDetails packageDetails;

bool reloading;

private Bridge() { }
private Bridge()
{
}

public void Setup(VisualElement root)
{
Expand Down Expand Up @@ -105,7 +112,7 @@ static bool UpdatePackageVersions(Package package, IEnumerable<AvailableVersion>

var versionInfos = versions
.Select(v => v.ToPackageVersion(pInfoCurrent))
.Concat(new[] { pInfoCurrent })
.Concat(new[] {pInfoCurrent})
.Where(pInfo => pInfo == pInfoCurrent || pInfo.GetVersion() != pInfoCurrent.GetVersion())
.OrderBy(pInfo => pInfo.GetVersion())
.ToArray();
Expand All @@ -116,6 +123,7 @@ static bool UpdatePackageVersions(Package package, IEnumerable<AvailableVersion>
package.UpdateVersions(versionInfos);
return true;
}

return false;
}

Expand All @@ -130,11 +138,10 @@ internal static class PackageExtensions
{
#if UNITY_2020_1_OR_NEWER

internal static PageManager PageManagerInstance =>
#if UNITY_2020_2_OR_NEWER
ServicesContainer.instance.Resolve<PageManager>();
internal static PageManager PageManagerInstance => ServicesContainer.instance.Resolve<PageManager>();
#else
PageManager.instance;
internal static IPageManager PageManagerInstance => PageManager.instance;
#endif

internal static void RegisterLoadedAction(this PackageList self, Action action)
Expand All @@ -153,7 +160,7 @@ internal static IEnumerable<UpmPackage> GetGitPackages()

internal static IEnumerable<UpmPackageVersion> GetGitPackageInfos()
{
return GetGitPackages().Select(x=>x.GetInstalledVersion());
return GetGitPackages().Select(x => x.GetInstalledVersion());
}

internal static UpmPackageVersion GetInstalledVersion(this UpmPackage self)
Expand Down Expand Up @@ -379,4 +386,4 @@ internal static PackageInfo ToPackageVersion(this AvailableVersion self, Package
#endif
}
}
#endif // [ASMDEFEX] DO NOT REMOVE THIS LINE MANUALLY.
#endif // [ASMDEFEX] DO NOT REMOVE THIS LINE MANUALLY.
5 changes: 3 additions & 2 deletions Editor/Coffee.UpmGitExtension/UI/GitButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#if UNITY_2019_1_OR_NEWER
using UnityEngine.UIElements;
using UnityEditor.UIElements;

#else
using UnityEngine.Experimental.UIElements;
using UnityEditor.Experimental.UIElements;
Expand All @@ -26,7 +27,7 @@ public static bool IsResourceReady()
public GitButton(System.Action action) : base(action)
{
#if UNITY_2019_1_OR_NEWER
styleSheets.Add (UnityEditor.AssetDatabase.LoadAssetAtPath<StyleSheet>(StylePath));
styleSheets.Add(UnityEditor.AssetDatabase.LoadAssetAtPath<StyleSheet>(StylePath));
#else
AddStyleSheetPath(StylePath);
#endif
Expand All @@ -40,4 +41,4 @@ public GitButton(System.Action action) : base(action)
}
}
}
#endif // [ASMDEFEX] DO NOT REMOVE THIS LINE MANUALLY.
#endif // [ASMDEFEX] DO NOT REMOVE THIS LINE MANUALLY.
11 changes: 6 additions & 5 deletions Editor/Coffee.UpmGitExtension/UI/InstallPackageWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using UnityEngine;
#if UNITY_2019_1_OR_NEWER
using UnityEngine.UIElements;

#else
using UnityEngine.Experimental.UIElements;
#endif
Expand Down Expand Up @@ -37,8 +38,8 @@ public InstallPackageWindow()
VisualTreeAsset asset = EditorGUIUtility.Load(TemplatePath) as VisualTreeAsset;

#if UNITY_2019_1_OR_NEWER
root = asset.CloneTree ();
styleSheets.Add (AssetDatabase.LoadAssetAtPath<StyleSheet> (StylePath));
root = asset.CloneTree();
styleSheets.Add(AssetDatabase.LoadAssetAtPath<StyleSheet>(StylePath));
#else
root = asset.CloneTree(null);
AddStyleSheetPath(StylePath);
Expand Down Expand Up @@ -69,13 +70,13 @@ public InstallPackageWindow()

// Url container
#if UNITY_2019_1_OR_NEWER
repoUrlText.RegisterValueChangedCallback ((evt) => onChange_RepoUrl (evt.newValue));
repoUrlText.RegisterValueChangedCallback((evt) => onChange_RepoUrl(evt.newValue));
#else
repoUrlText.OnValueChanged ((evt) => onChange_RepoUrl(evt.newValue));
#endif

#if UNITY_2019_3_OR_NEWER
subDirText.RegisterValueChangedCallback ((evt) => onChange_RepoUrl (repoUrlText.value));
subDirText.RegisterValueChangedCallback((evt) => onChange_RepoUrl(repoUrlText.value));
UIUtils.SetElementDisplay(root.Q("subDirContainer"), true);
#else
UIUtils.SetElementDisplay(root.Q("subDirContainer"), false);
Expand Down Expand Up @@ -225,4 +226,4 @@ public static string GetRepoUrl(string url, string path)
}
}
}
#endif // [ASMDEFEX] DO NOT REMOVE THIS LINE MANUALLY.
#endif // [ASMDEFEX] DO NOT REMOVE THIS LINE MANUALLY.
15 changes: 11 additions & 4 deletions Editor/Coffee.UpmGitExtension/UI/PackageDetailsExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void Setup(VisualElement root)
var hostButton = packageDetails.Q<Button>("hostButton");
if (hostButton == null)
{
hostButton = new Button(ViewRepoClick) { name = "hostButton", tooltip = "View on browser" };
hostButton = new Button(ViewRepoClick) {name = "hostButton", tooltip = "View on browser"};
hostButton.RemoveFromClassList("unity-button");
hostButton.RemoveFromClassList("button");
hostButton.AddToClassList("link");
Expand Down Expand Up @@ -109,8 +109,15 @@ public void OnPackageSelectionChange(PackageInfo packageInfo)
PackageDetails packageDetails;

#if UNITY_2019_3_OR_NEWER
PackageInfo GetSelectedPackage() { return GetSelectedVersion().packageInfo; }
UpmPackageVersion GetSelectedVersion() { return packageDetails.targetVersion as UpmPackageVersion; }
PackageInfo GetSelectedPackage()
{
return GetSelectedVersion().packageInfo;
}

UpmPackageVersion GetSelectedVersion()
{
return packageDetails.targetVersion as UpmPackageVersion;
}
#elif UNITY_2019_1_OR_NEWER
PackageInfo GetSelectedPackage() { return GetSelectedVersion().Info; }
UnityEditor.PackageManager.UI.PackageInfo GetSelectedVersion() { return packageDetails.TargetVersion; }
Expand Down Expand Up @@ -257,4 +264,4 @@ public void ViewLicensesClick()
#endif
}
}
#endif // [ASMDEFEX] DO NOT REMOVE THIS LINE MANUALLY.
#endif // [ASMDEFEX] DO NOT REMOVE THIS LINE MANUALLY.
5 changes: 3 additions & 2 deletions Editor/Coffee.UpmGitExtension/UpmGitExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using PackageInfo = UnityEditor.PackageManager.PackageInfo;
#if UNITY_2019_1_OR_NEWER
using UnityEngine.UIElements;

#else
using UnityEngine.Experimental.UIElements;
#endif
Expand All @@ -17,6 +18,7 @@ internal class UpmGitExtension : VisualElement, IPackageManagerExtension
// Constant or Static Members.
//################################
const string kHeader = "<b><color=#c7634c>[UpmGitExtension]</color></b> ";

static UpmGitExtension()
{
PackageManagerExtensions.RegisterExtension(new UpmGitExtension());
Expand Down Expand Up @@ -109,8 +111,7 @@ void InitializeUI()
space.style.flexGrow = 1;
addButton.parent.Insert(addButton.parent.IndexOf(addButton), space);
#endif

}
}
}
#endif // [ASMDEFEX] DO NOT REMOVE THIS LINE MANUALLY.
#endif // [ASMDEFEX] DO NOT REMOVE THIS LINE MANUALLY.
Loading

0 comments on commit ecf4c7d

Please sign in to comment.