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