Unity Package 모두 업데이트(Package All Update)
Unity Editor Coroutine을 사용해서
포함된 패키지를 모두 다 업데이트하는 코드이다.
반응형
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.PackageManager;
using UnityEngine;
using Unity.EditorCoroutines.Editor;
static class PackagesUtill
{
[MenuItem("Packages/Update All Packages")]
private static void UpdateAllPackages()
{
EditorCoroutineUtility.StartCoroutineOwnerless(UpdatePackages());
}
[MenuItem("Packages/Show Package Name")]
private static void ShowPackageName()
{
EditorCoroutineUtility.StartCoroutineOwnerless(ShowRoutine());
}
private static IEnumerator ShowRoutine()
{
var listToUpdate = new List<string>();
var listRequest = Client.List();
while (!listRequest.IsCompleted)
{
yield return new WaitForSeconds(0.1f);
}
var packageCollection = listRequest.Result;
foreach (var package in packageCollection)
{
if (!package.isDirectDependency)
{
continue;
}
Debug.Log($"[CheckPackages] {package.name}");
}
}
private static IEnumerator UpdatePackages()
{
var listToUpdate = new List<string>();
var listRequest = Client.List();
while (!listRequest.IsCompleted)
{
yield return new WaitForSeconds(0.1f);
}
var packageCollection = listRequest.Result;
foreach (var package in packageCollection)
{
if (!package.isDirectDependency)
{
continue;
}
Debug.Log($"[CheckPackages] {package.name}");
var targetVersion = string.Empty;
for (var i = package.versions.compatible.Length - 1; i >= 0; i--)
{
var version = package.versions.compatible[i];
if (version.Contains("pre") || version.Contains("exp"))
{
continue;
}
targetVersion = version;
break;
}
listToUpdate.Add($"{package.name}@{targetVersion}");
}
Client.AddAndRemove(listToUpdate.ToArray(), Array.Empty<string>());
}
}
사진
★☆☆
반응형
'개발 > Unity' 카테고리의 다른 글
Unity) Crash Report (0) | 2023.07.24 |
---|---|
Unity) TextMeshPro Rich Text Tag 정리(Color, Size, Mark, Sprite...etc : 문자 효과) (0) | 2023.07.22 |
Unity) LOD(Level Of Detail) 와 MinMap의 차이 (0) | 2023.07.16 |
문제해결)Unity Project 문제 발생 시 초기화하기 (0) | 2023.07.15 |
Unity) Import Activity (Asset Import 정보 확인) (0) | 2023.07.13 |
댓글