diff --git a/Editor/PackageUpdater.cs b/Editor/PackageUpdater.cs new file mode 100644 index 0000000..1e195d5 --- /dev/null +++ b/Editor/PackageUpdater.cs @@ -0,0 +1,49 @@ +using System.IO; +using UnityEditor; +using UnityEngine; + +namespace Agoxandr.Utils +{ + public class PackgeUpdater + { + private static string ManifestPath + { + get + { + var projectPath = Directory.GetParent(Application.dataPath).FullName; + var manifestPath = Path.Combine(projectPath, "Packages", "manifest.json"); + return manifestPath; + } + } + + public static string GetStringBetweenCharacters(string input, char charFrom, char charTo) + { + int posFrom = input.IndexOf(charFrom); + if (posFrom != -1) //if found char + { + int posTo = input.IndexOf(charTo, posFrom + 1); + if (posTo != -1) //if found char + { + return input.Substring(posFrom + 1, posTo - posFrom - 1); + } + } + + return string.Empty; + } + + [MenuItem("Assets/Update Git Packages", false, 20)] + private static void UpdateGitPackages() + { + var lines = File.ReadAllLines(ManifestPath); + foreach (var line in lines) + { + if (line.Contains("git")) + { + var identifier = GetStringBetweenCharacters(line, '"', '"'); + Debug.Log("Checking for updates " + identifier); + UnityEditor.PackageManager.Client.Add(identifier); + } + } + } + } +} diff --git a/Editor/PackageUpdater.cs.meta b/Editor/PackageUpdater.cs.meta new file mode 100644 index 0000000..f28439e --- /dev/null +++ b/Editor/PackageUpdater.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ce75a6f4e95d89b4eba151eb7d16a6ff +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/package.json b/package.json index 0127c0a..6dabfe7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "de.agoxandr.utils", - "version": "2.5.1", + "version": "2.6.0", "displayName": "Utils", "description": "Utility useful for almost any project.", "licensesUrl": "https://github.com/Agoxandr/Utils/blob/master/LICENSE.md",