mirror of https://github.com/tuyoogame/YooAsset
parent
460ea091bd
commit
9418544264
|
@ -75,6 +75,11 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EVerifyLevel CacheBootVerifyLevel = EVerifyLevel.Middle;
|
public EVerifyLevel CacheBootVerifyLevel = EVerifyLevel.Middle;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自动销毁不再使用的资源提供者
|
||||||
|
/// </summary>
|
||||||
|
public bool AutoDestroyAssetProvider = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源加载每帧处理的最大时间片段
|
/// 资源加载每帧处理的最大时间片段
|
||||||
/// 注意:默认值为MaxValue
|
/// 注意:默认值为MaxValue
|
||||||
|
|
|
@ -134,7 +134,11 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移除资源提供者
|
// 移除资源提供者
|
||||||
|
if (_removeList.Count > 0)
|
||||||
|
{
|
||||||
Impl.RemoveBundleProviders(_removeList);
|
Impl.RemoveBundleProviders(_removeList);
|
||||||
|
_removeList.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
_asyncOp = SceneManager.UnloadSceneAsync(_provider.SceneObject);
|
_asyncOp = SceneManager.UnloadSceneAsync(_provider.SceneObject);
|
||||||
_provider.ResourceMgr.UnloadSubScene(_provider.SceneName);
|
_provider.ResourceMgr.UnloadSubScene(_provider.SceneName);
|
||||||
|
_provider.ResourceMgr.TryUnloadUnusedAsset(_provider.MainAssetInfo);
|
||||||
_steps = ESteps.Checking;
|
_steps = ESteps.Checking;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ namespace YooAsset
|
||||||
|
|
||||||
|
|
||||||
private bool _simulationOnEditor;
|
private bool _simulationOnEditor;
|
||||||
|
private bool _autoDestroyAssetProvider;
|
||||||
private long _loadingMaxTimeSlice;
|
private long _loadingMaxTimeSlice;
|
||||||
private IBundleQuery _bundleQuery;
|
private IBundleQuery _bundleQuery;
|
||||||
private bool _isUnloadSafe = true;
|
private bool _isUnloadSafe = true;
|
||||||
|
@ -49,9 +50,10 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化
|
/// 初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Initialize(bool simulationOnEditor, long loadingMaxTimeSlice, IBundleQuery bundleServices)
|
public void Initialize(bool simulationOnEditor, bool autoDestroyAssetProvider, long loadingMaxTimeSlice, IBundleQuery bundleServices)
|
||||||
{
|
{
|
||||||
_simulationOnEditor = simulationOnEditor;
|
_simulationOnEditor = simulationOnEditor;
|
||||||
|
_autoDestroyAssetProvider = autoDestroyAssetProvider;
|
||||||
_loadingMaxTimeSlice = loadingMaxTimeSlice;
|
_loadingMaxTimeSlice = loadingMaxTimeSlice;
|
||||||
_bundleQuery = bundleServices;
|
_bundleQuery = bundleServices;
|
||||||
_watch = Stopwatch.StartNew();
|
_watch = Stopwatch.StartNew();
|
||||||
|
@ -68,6 +70,9 @@ namespace YooAsset
|
||||||
foreach (var loader in _loaderList)
|
foreach (var loader in _loaderList)
|
||||||
{
|
{
|
||||||
loader.Update();
|
loader.Update();
|
||||||
|
|
||||||
|
if (_autoDestroyAssetProvider)
|
||||||
|
loader.TryDestroyProviders();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新资源提供者
|
// 更新资源提供者
|
||||||
|
|
|
@ -146,7 +146,7 @@ namespace YooAsset
|
||||||
var editorSimulateModeImpl = new EditorSimulateModeImpl(PackageName);
|
var editorSimulateModeImpl = new EditorSimulateModeImpl(PackageName);
|
||||||
_bundleQuery = editorSimulateModeImpl;
|
_bundleQuery = editorSimulateModeImpl;
|
||||||
_playModeImpl = editorSimulateModeImpl;
|
_playModeImpl = editorSimulateModeImpl;
|
||||||
_resourceMgr.Initialize(true, parameters.LoadingMaxTimeSlice, _bundleQuery);
|
_resourceMgr.Initialize(true, parameters.AutoDestroyAssetProvider, parameters.LoadingMaxTimeSlice, _bundleQuery);
|
||||||
|
|
||||||
var initializeParameters = parameters as EditorSimulateModeParameters;
|
var initializeParameters = parameters as EditorSimulateModeParameters;
|
||||||
initializeOperation = editorSimulateModeImpl.InitializeAsync(assist, initializeParameters.SimulateManifestFilePath);
|
initializeOperation = editorSimulateModeImpl.InitializeAsync(assist, initializeParameters.SimulateManifestFilePath);
|
||||||
|
@ -156,7 +156,7 @@ namespace YooAsset
|
||||||
var offlinePlayModeImpl = new OfflinePlayModeImpl(PackageName);
|
var offlinePlayModeImpl = new OfflinePlayModeImpl(PackageName);
|
||||||
_bundleQuery = offlinePlayModeImpl;
|
_bundleQuery = offlinePlayModeImpl;
|
||||||
_playModeImpl = offlinePlayModeImpl;
|
_playModeImpl = offlinePlayModeImpl;
|
||||||
_resourceMgr.Initialize(false, parameters.LoadingMaxTimeSlice, _bundleQuery);
|
_resourceMgr.Initialize(false, parameters.AutoDestroyAssetProvider, parameters.LoadingMaxTimeSlice, _bundleQuery);
|
||||||
|
|
||||||
var initializeParameters = parameters as OfflinePlayModeParameters;
|
var initializeParameters = parameters as OfflinePlayModeParameters;
|
||||||
initializeOperation = offlinePlayModeImpl.InitializeAsync(assist);
|
initializeOperation = offlinePlayModeImpl.InitializeAsync(assist);
|
||||||
|
@ -166,7 +166,7 @@ namespace YooAsset
|
||||||
var hostPlayModeImpl = new HostPlayModeImpl(PackageName);
|
var hostPlayModeImpl = new HostPlayModeImpl(PackageName);
|
||||||
_bundleQuery = hostPlayModeImpl;
|
_bundleQuery = hostPlayModeImpl;
|
||||||
_playModeImpl = hostPlayModeImpl;
|
_playModeImpl = hostPlayModeImpl;
|
||||||
_resourceMgr.Initialize(false, parameters.LoadingMaxTimeSlice, _bundleQuery);
|
_resourceMgr.Initialize(false, parameters.AutoDestroyAssetProvider, parameters.LoadingMaxTimeSlice, _bundleQuery);
|
||||||
|
|
||||||
var initializeParameters = parameters as HostPlayModeParameters;
|
var initializeParameters = parameters as HostPlayModeParameters;
|
||||||
initializeOperation = hostPlayModeImpl.InitializeAsync(assist,
|
initializeOperation = hostPlayModeImpl.InitializeAsync(assist,
|
||||||
|
@ -179,7 +179,7 @@ namespace YooAsset
|
||||||
var webPlayModeImpl = new WebPlayModeImpl(PackageName);
|
var webPlayModeImpl = new WebPlayModeImpl(PackageName);
|
||||||
_bundleQuery = webPlayModeImpl;
|
_bundleQuery = webPlayModeImpl;
|
||||||
_playModeImpl = webPlayModeImpl;
|
_playModeImpl = webPlayModeImpl;
|
||||||
_resourceMgr.Initialize(false, parameters.LoadingMaxTimeSlice, _bundleQuery);
|
_resourceMgr.Initialize(false, parameters.AutoDestroyAssetProvider, parameters.LoadingMaxTimeSlice, _bundleQuery);
|
||||||
|
|
||||||
var initializeParameters = parameters as WebPlayModeParameters;
|
var initializeParameters = parameters as WebPlayModeParameters;
|
||||||
initializeOperation = webPlayModeImpl.InitializeAsync(assist,
|
initializeOperation = webPlayModeImpl.InitializeAsync(assist,
|
||||||
|
|
Loading…
Reference in New Issue