自动检测并导入Scriptablebuildpipeline

pull/274/head
ALEXTANG 2024-04-09 15:30:08 +08:00
parent 1461b91a94
commit 77e8bef666
2 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,36 @@
using UnityEditor;
using UnityEditor.PackageManager;
using UnityEngine;
namespace YooAsset.Editor
{
/// <summary>
/// 自动导入SBP依赖类
/// </summary>
[InitializeOnLoad]
public static class SBPPackageImporter
{
static SBPPackageImporter()
{
InstallPackage("com.unity.scriptablebuildpipeline");
}
private static bool IsPackageInstalled(string packageName)
{
return UnityEditor.PackageManager.PackageInfo.FindForAssetPath($"Packages/{packageName}") != null;
}
public static bool InstallPackage(string packageName)
{
if (IsPackageInstalled(packageName))
{
return false;
}
Debug.Log($"Install...{packageName}");
var request = Client.Add(packageName);
while (!request.IsCompleted) { };
if (request.Error != null) Debug.LogError(request.Error.message);
return request.Error == null;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7bed458456c04424bcee443f2eecb6ad
timeCreated: 1712647319