mirror of https://github.com/tuyoogame/YooAsset
自动检测并导入Scriptablebuildpipeline
parent
1461b91a94
commit
77e8bef666
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7bed458456c04424bcee443f2eecb6ad
|
||||||
|
timeCreated: 1712647319
|
Loading…
Reference in New Issue