111
All checks were successful
Plugin Library CI / publish (00.BuildOriginality) (push) Successful in 5s
Plugin Library CI / publish (00.StaryEvo) (push) Successful in 7s
Plugin Library CI / publish (00.StaryEvoTools) (push) Successful in 22s
Plugin Library CI / publish (01.HybridCLR) (push) Successful in 7s
Plugin Library CI / publish (02.InformationSave) (push) Successful in 3s
Plugin Library CI / publish (03.YooAsset) (push) Successful in 35s
Plugin Library CI / publish (04.AudioCore) (push) Successful in 3s
Plugin Library CI / publish (05.TableTextConversion) (push) Successful in 4s
Plugin Library CI / publish (06.UIFarme) (push) Successful in 18s
Plugin Library CI / publish (07.RKTools) (push) Successful in 3s
Plugin Library CI / publish (11.PointCloudTools) (push) Successful in 4s
Plugin Library CI / publish (12.WeixinMinigame) (push) Successful in 1m5s
Plugin Library CI / publish (08.UniTask) (push) Successful in 4s
Plugin Library CI / publish (09.CodeChecker) (push) Successful in 19s
Plugin Library CI / publish (10.StoryEditor) (push) Successful in 5s
Plugin Library CI / publish (10.XNode) (push) Successful in 3s
All checks were successful
Plugin Library CI / publish (00.BuildOriginality) (push) Successful in 5s
Plugin Library CI / publish (00.StaryEvo) (push) Successful in 7s
Plugin Library CI / publish (00.StaryEvoTools) (push) Successful in 22s
Plugin Library CI / publish (01.HybridCLR) (push) Successful in 7s
Plugin Library CI / publish (02.InformationSave) (push) Successful in 3s
Plugin Library CI / publish (03.YooAsset) (push) Successful in 35s
Plugin Library CI / publish (04.AudioCore) (push) Successful in 3s
Plugin Library CI / publish (05.TableTextConversion) (push) Successful in 4s
Plugin Library CI / publish (06.UIFarme) (push) Successful in 18s
Plugin Library CI / publish (07.RKTools) (push) Successful in 3s
Plugin Library CI / publish (11.PointCloudTools) (push) Successful in 4s
Plugin Library CI / publish (12.WeixinMinigame) (push) Successful in 1m5s
Plugin Library CI / publish (08.UniTask) (push) Successful in 4s
Plugin Library CI / publish (09.CodeChecker) (push) Successful in 19s
Plugin Library CI / publish (10.StoryEditor) (push) Successful in 5s
Plugin Library CI / publish (10.XNode) (push) Successful in 3s
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.UIFarme
|
||||
{
|
||||
/// <summary>
|
||||
/// 基于Resources的资源加载实现
|
||||
/// </summary>
|
||||
public class ResourcesAssetLoader : IAssetLoader
|
||||
{
|
||||
private readonly Dictionary<string, Object> _assetCache = new Dictionary<string, Object>();
|
||||
|
||||
/// <summary>
|
||||
/// 通过Resources异步加载GameObject资源
|
||||
/// </summary>
|
||||
public async Task<GameObject> LoadGameObjectAsync(string assetPath, string packageName = null)
|
||||
{
|
||||
// Resources模式下忽略packageName
|
||||
var request = Resources.LoadAsync<GameObject>(assetPath);
|
||||
while (!request.isDone)
|
||||
{
|
||||
await Task.Yield();
|
||||
}
|
||||
|
||||
var asset = request.asset as GameObject;
|
||||
if (asset != null)
|
||||
{
|
||||
_assetCache[assetPath] = asset;
|
||||
}
|
||||
|
||||
return asset;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放Resources加载的资源
|
||||
/// </summary>
|
||||
public void UnloadAsset(string assetPath)
|
||||
{
|
||||
if (_assetCache.TryGetValue(assetPath, out Object asset) && asset != null)
|
||||
{
|
||||
Resources.UnloadAsset(asset);
|
||||
_assetCache.Remove(assetPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user