Package updater
This commit is contained in:
parent
6ce5763141
commit
da1148655d
49
Editor/PackageUpdater.cs
Normal file
49
Editor/PackageUpdater.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Editor/PackageUpdater.cs.meta
Normal file
11
Editor/PackageUpdater.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ce75a6f4e95d89b4eba151eb7d16a6ff
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "de.agoxandr.utils",
|
"name": "de.agoxandr.utils",
|
||||||
"version": "2.5.1",
|
"version": "2.6.0",
|
||||||
"displayName": "Utils",
|
"displayName": "Utils",
|
||||||
"description": "Utility useful for almost any project.",
|
"description": "Utility useful for almost any project.",
|
||||||
"licensesUrl": "https://github.com/Agoxandr/Utils/blob/master/LICENSE.md",
|
"licensesUrl": "https://github.com/Agoxandr/Utils/blob/master/LICENSE.md",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user