Package updater

This commit is contained in:
Alexander Filippov 2021-06-27 20:07:38 +02:00
parent 6ce5763141
commit da1148655d
3 changed files with 61 additions and 1 deletions

49
Editor/PackageUpdater.cs Normal file
View File

@ -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);
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ce75a6f4e95d89b4eba151eb7d16a6ff
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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",