mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
资源模块优化、UI模块优化,增加接口参数是否使用缓存资源操作句柄。
资源模块优化、UI模块优化,增加接口参数是否使用缓存资源操作句柄、如果需要则不会淘汰缓存队列中的资源清单。
This commit is contained in:
@@ -400,7 +400,7 @@ namespace TEngine
|
||||
throw new Exception($"Window {type.FullName} not found {nameof(WindowAttribute)} attribute.");
|
||||
|
||||
string assetName = string.IsNullOrEmpty(attribute.Location) ? type.Name : attribute.Location;
|
||||
window.Init(type.FullName, attribute.WindowLayer, attribute.FullScreen, assetName, attribute.FromResources);
|
||||
window.Init(type.FullName, attribute.WindowLayer, attribute.FullScreen, assetName, attribute.FromResources, attribute.NeedCache);
|
||||
return window;
|
||||
}
|
||||
|
||||
|
@@ -66,6 +66,11 @@ namespace TEngine
|
||||
/// 是内部资源无需AB加载。
|
||||
/// </summary>
|
||||
public bool FromResources { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否需要缓存。
|
||||
/// </summary>
|
||||
public bool NeedCache { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义数据。
|
||||
@@ -221,13 +226,14 @@ namespace TEngine
|
||||
|
||||
#endregion
|
||||
|
||||
public void Init(string name, int layer, bool fullScreen, string assetName, bool fromResources)
|
||||
public void Init(string name, int layer, bool fullScreen, string assetName, bool fromResources, bool needCache = false)
|
||||
{
|
||||
WindowName = name;
|
||||
WindowLayer = layer;
|
||||
FullScreen = fullScreen;
|
||||
AssetName = assetName;
|
||||
FromResources = fromResources;
|
||||
NeedCache = needCache;
|
||||
}
|
||||
|
||||
internal void TryInvoke(System.Action<UIWindow> prepareCallback, System.Object[] userDatas)
|
||||
@@ -249,7 +255,7 @@ namespace TEngine
|
||||
this.userDatas = userDatas;
|
||||
if (!FromResources)
|
||||
{
|
||||
GameModule.Resource.LoadAssetAsync<GameObject>(location, Handle_Completed);
|
||||
GameModule.Resource.LoadAssetAsync<GameObject>(location, Handle_Completed, needCache: NeedCache);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -392,6 +398,10 @@ namespace TEngine
|
||||
|
||||
// 实例化对象
|
||||
var panel = handle.InstantiateSync(UIModule.UIRootStatic);
|
||||
if (!NeedCache)
|
||||
{
|
||||
AssetReference.BindAssetReference(panel, handle, AssetName);
|
||||
}
|
||||
Handle_Completed(panel);
|
||||
}
|
||||
|
||||
|
@@ -37,31 +37,41 @@ namespace TEngine
|
||||
/// </summary>
|
||||
public readonly bool FromResources;
|
||||
|
||||
public WindowAttribute(int windowLayer, string location = "", bool fullScreen = false)
|
||||
/// <summary>
|
||||
/// 需要缓存。
|
||||
/// <remarks>关闭界面不立刻释放资源。</remarks>
|
||||
/// </summary>
|
||||
public readonly bool NeedCache;
|
||||
|
||||
public WindowAttribute(int windowLayer, string location = "", bool fullScreen = false,bool needCache = false)
|
||||
{
|
||||
WindowLayer = windowLayer;
|
||||
Location = location;
|
||||
FullScreen = fullScreen;
|
||||
NeedCache = needCache;
|
||||
}
|
||||
|
||||
public WindowAttribute(UILayer windowLayer, string location = "", bool fullScreen = false)
|
||||
public WindowAttribute(UILayer windowLayer, string location = "", bool fullScreen = false,bool needCache = false)
|
||||
{
|
||||
WindowLayer = (int)windowLayer;
|
||||
Location = location;
|
||||
FullScreen = fullScreen;
|
||||
NeedCache = needCache;
|
||||
}
|
||||
|
||||
public WindowAttribute(UILayer windowLayer, bool fromResources, bool fullScreen = false)
|
||||
public WindowAttribute(UILayer windowLayer, bool fromResources, bool fullScreen = false,bool needCache = false)
|
||||
{
|
||||
WindowLayer = (int)windowLayer;
|
||||
FromResources = fromResources;
|
||||
NeedCache = needCache;
|
||||
}
|
||||
|
||||
public WindowAttribute(UILayer windowLayer, bool fromResources, string location, bool fullScreen = false)
|
||||
public WindowAttribute(UILayer windowLayer, bool fromResources, string location, bool fullScreen = false,bool needCache = false)
|
||||
{
|
||||
WindowLayer = (int)windowLayer;
|
||||
FromResources = fromResources;
|
||||
Location = location;
|
||||
NeedCache = needCache;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user