1.进步优化UI系统 加载问题 性能问题 Canvas重绘问题 边界处理问题 2.优化对象池和游戏对象池的性能 游戏对象池根据窗口 策略定期清理 3.优化整个AppService 和ServiceWorld结构 固定三大类 具体参考代码
69 lines
1.9 KiB
C#
69 lines
1.9 KiB
C#
using AlicizaX.ObjectPool;
|
|
using AlicizaX;
|
|
|
|
namespace AlicizaX.Resource.Runtime
|
|
{
|
|
internal partial class ResourceService
|
|
{
|
|
private IObjectPool<AssetObject> _assetPool;
|
|
|
|
/// <summary>
|
|
/// 获取或设置资源对象池自动释放可释放对象的间隔秒数。
|
|
/// </summary>
|
|
public float AssetAutoReleaseInterval
|
|
{
|
|
get => _assetPool.AutoReleaseInterval;
|
|
set => _assetPool.AutoReleaseInterval = value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取或设置资源对象池的容量。
|
|
/// </summary>
|
|
public int AssetCapacity
|
|
{
|
|
get => _assetPool.Capacity;
|
|
set => _assetPool.Capacity = value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取或设置资源对象池对象过期秒数。
|
|
/// </summary>
|
|
public float AssetExpireTime
|
|
{
|
|
get => _assetPool.ExpireTime;
|
|
set => _assetPool.ExpireTime = value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取或设置资源对象池的优先级。
|
|
/// </summary>
|
|
public int AssetPriority
|
|
{
|
|
get => _assetPool.Priority;
|
|
set => _assetPool.Priority = value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 卸载资源。
|
|
/// </summary>
|
|
/// <param name="asset">要卸载的资源。</param>
|
|
public void UnloadAsset(object asset)
|
|
{
|
|
if (_assetPool != null)
|
|
{
|
|
_assetPool.Unspawn(asset);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置对象池管理器。
|
|
/// </summary>
|
|
/// <param name="objectPoolModule">对象池管理器。</param>
|
|
public void CreateAssetPool( )
|
|
{
|
|
_assetPool = Context.Require<IObjectPoolService>().CreatePool<AssetObject>(
|
|
ObjectPoolCreateOptions.Multi("Asset Pool"));
|
|
}
|
|
}
|
|
}
|