mirror of https://github.com/tuyoogame/YooAsset
parent
f06bd83dc3
commit
b5ffd5005a
|
@ -100,29 +100,21 @@ namespace YooAsset
|
|||
if (IsValidWithWarning == false)
|
||||
return false;
|
||||
|
||||
// 注意:当场景挂起操作执行之后无法中途取消!
|
||||
if (SceneObject.IsValid())
|
||||
{
|
||||
if (Provider is DatabaseSceneProvider)
|
||||
{
|
||||
var temp = Provider as DatabaseSceneProvider;
|
||||
return temp.UnSuspendLoad();
|
||||
var provider = Provider as DatabaseSceneProvider;
|
||||
provider.UnSuspendLoad();
|
||||
}
|
||||
else if (Provider is BundledSceneProvider)
|
||||
{
|
||||
var temp = Provider as BundledSceneProvider;
|
||||
return temp.UnSuspendLoad();
|
||||
var provider = Provider as BundledSceneProvider;
|
||||
provider.UnSuspendLoad();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning($"Scene is invalid : {SceneObject.name}");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -9,14 +9,14 @@ namespace YooAsset
|
|||
internal sealed class BundledSceneProvider : ProviderBase
|
||||
{
|
||||
public readonly LoadSceneMode SceneMode;
|
||||
private readonly bool _suspendLoad;
|
||||
private AsyncOperation _asyncOperation;
|
||||
private bool _suspendLoadMode;
|
||||
|
||||
public BundledSceneProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, bool suspendLoad) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
SceneMode = sceneMode;
|
||||
SceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath);
|
||||
_suspendLoad = suspendLoad;
|
||||
_suspendLoadMode = suspendLoad;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ namespace YooAsset
|
|||
_asyncOperation = SceneManager.LoadSceneAsync(MainAssetInfo.AssetPath, SceneMode);
|
||||
if (_asyncOperation != null)
|
||||
{
|
||||
_asyncOperation.allowSceneActivation = !_suspendLoad;
|
||||
_asyncOperation.allowSceneActivation = !_suspendLoadMode;
|
||||
_asyncOperation.priority = 100;
|
||||
SceneObject = SceneManager.GetSceneAt(SceneManager.sceneCount - 1);
|
||||
_steps = ESteps.Checking;
|
||||
|
@ -106,6 +106,13 @@ namespace YooAsset
|
|||
}
|
||||
else
|
||||
{
|
||||
// 注意:在业务层中途可以取消挂起
|
||||
if (_asyncOperation.allowSceneActivation == false)
|
||||
{
|
||||
if (_suspendLoadMode == false)
|
||||
_asyncOperation.allowSceneActivation = true;
|
||||
}
|
||||
|
||||
Progress = _asyncOperation.progress;
|
||||
if (_asyncOperation.isDone == false)
|
||||
return;
|
||||
|
@ -128,13 +135,12 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 解除场景加载挂起操作
|
||||
/// </summary>
|
||||
public bool UnSuspendLoad()
|
||||
public void UnSuspendLoad()
|
||||
{
|
||||
if (_asyncOperation == null)
|
||||
return false;
|
||||
|
||||
_asyncOperation.allowSceneActivation = true;
|
||||
return true;
|
||||
if (IsDone == false)
|
||||
{
|
||||
_suspendLoadMode = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,14 +9,14 @@ namespace YooAsset
|
|||
internal sealed class DatabaseSceneProvider : ProviderBase
|
||||
{
|
||||
public readonly LoadSceneMode SceneMode;
|
||||
private readonly bool _suspendLoad;
|
||||
private bool _suspendLoadMode;
|
||||
private AsyncOperation _asyncOperation;
|
||||
|
||||
public DatabaseSceneProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, bool suspendLoad) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
SceneMode = sceneMode;
|
||||
SceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath);
|
||||
_suspendLoad = suspendLoad;
|
||||
_suspendLoadMode = suspendLoad;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ namespace YooAsset
|
|||
_asyncOperation = UnityEditor.SceneManagement.EditorSceneManager.LoadSceneAsyncInPlayMode(MainAssetInfo.AssetPath, loadSceneParameters);
|
||||
if (_asyncOperation != null)
|
||||
{
|
||||
_asyncOperation.allowSceneActivation = !_suspendLoad;
|
||||
_asyncOperation.allowSceneActivation = !_suspendLoadMode;
|
||||
_asyncOperation.priority = 100;
|
||||
SceneObject = SceneManager.GetSceneAt(SceneManager.sceneCount - 1);
|
||||
_steps = ESteps.Checking;
|
||||
|
@ -95,6 +95,13 @@ namespace YooAsset
|
|||
}
|
||||
else
|
||||
{
|
||||
// 注意:在业务层中途可以取消挂起
|
||||
if (_asyncOperation.allowSceneActivation == false)
|
||||
{
|
||||
if (_suspendLoadMode == false)
|
||||
_asyncOperation.allowSceneActivation = true;
|
||||
}
|
||||
|
||||
Progress = _asyncOperation.progress;
|
||||
if (_asyncOperation.isDone == false)
|
||||
return;
|
||||
|
@ -118,13 +125,12 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 解除场景加载挂起操作
|
||||
/// </summary>
|
||||
public bool UnSuspendLoad()
|
||||
public void UnSuspendLoad()
|
||||
{
|
||||
if (_asyncOperation == null)
|
||||
return false;
|
||||
|
||||
_asyncOperation.allowSceneActivation = true;
|
||||
return true;
|
||||
if (IsDone == false)
|
||||
{
|
||||
_suspendLoadMode = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue