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,25 @@
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.UIFarme
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源加载策略接口,用于抽象不同的资源加载方式(如YooAsset、Resources等)
|
||||
/// </summary>
|
||||
public interface IAssetLoader
|
||||
{
|
||||
/// <summary>
|
||||
/// 异步加载GameObject资源
|
||||
/// </summary>
|
||||
/// <param name="assetPath">资源路径</param>
|
||||
/// <param name="packageName">YooAsset包名,Resources模式可忽略</param>
|
||||
/// <returns>加载到的GameObject资源(非实例,是原始Prefab)</returns>
|
||||
Task<GameObject> LoadGameObjectAsync(string assetPath, string packageName = null);
|
||||
|
||||
/// <summary>
|
||||
/// 卸载指定资源,释放底层资源句柄
|
||||
/// </summary>
|
||||
/// <param name="assetPath">资源路径</param>
|
||||
void UnloadAsset(string assetPath);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eee0c2ac899cda04d8ec4a2bb7687195
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21c72a85d6a282940bb331dfd1c926fd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user