update runtime code

1. 移除了LoadSceneAsync方法里的activateOnLoad参数
pull/122/head
hevinci 2023-06-27 15:04:47 +08:00
parent f54c8d6da4
commit 19c46a2f60
6 changed files with 16 additions and 30 deletions

View File

@ -169,7 +169,7 @@ namespace YooAsset
/// <summary>
/// 加载场景
/// </summary>
public SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode, bool activateOnLoad, int priority)
public SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode, int priority)
{
if (assetInfo.IsInvalid)
{
@ -190,9 +190,9 @@ namespace YooAsset
ProviderBase provider;
{
if (_simulationOnEditor)
provider = new DatabaseSceneProvider(this, providerGUID, assetInfo, sceneMode, activateOnLoad, priority);
provider = new DatabaseSceneProvider(this, providerGUID, assetInfo, sceneMode, priority);
else
provider = new BundledSceneProvider(this, providerGUID, assetInfo, sceneMode, activateOnLoad, priority);
provider = new BundledSceneProvider(this, providerGUID, assetInfo, sceneMode, priority);
provider.InitSpawnDebugInfo();
_providerList.Add(provider);
_providerDic.Add(providerGUID, provider);

View File

@ -3,7 +3,7 @@
namespace YooAsset
{
public class SceneOperationHandle : OperationHandleBase
{
{
private System.Action<SceneOperationHandle> _callback;
internal string PackageName { set; get; }
@ -51,7 +51,7 @@ namespace YooAsset
}
/// <summary>
/// 激活场景
/// 激活场景(当同时存在多个场景时用于切换激活场景)
/// </summary>
public bool ActivateScene()
{

View File

@ -10,15 +10,13 @@ namespace YooAsset
{
public readonly LoadSceneMode SceneMode;
private readonly string _sceneName;
private readonly bool _activateOnLoad;
private readonly int _priority;
private AsyncOperation _asyncOp;
public BundledSceneProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, bool activateOnLoad, int priority) : base(impl, providerGUID, assetInfo)
public BundledSceneProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, int priority) : base(impl, providerGUID, assetInfo)
{
SceneMode = sceneMode;
_sceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath);
_activateOnLoad = activateOnLoad;
_priority = priority;
}
public override void Update()
@ -87,9 +85,6 @@ namespace YooAsset
Progress = _asyncOp.progress;
if (_asyncOp.isDone)
{
if (SceneObject.IsValid() && _activateOnLoad)
SceneManager.SetActiveScene(SceneObject);
Status = SceneObject.IsValid() ? EStatus.Succeed : EStatus.Failed;
if (Status == EStatus.Failed)
{

View File

@ -6,14 +6,12 @@ namespace YooAsset
internal sealed class DatabaseSceneProvider : ProviderBase
{
public readonly LoadSceneMode SceneMode;
private readonly bool _activateOnLoad;
private readonly int _priority;
private AsyncOperation _asyncOp;
public DatabaseSceneProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, bool activateOnLoad, int priority) : base(impl, providerGUID, assetInfo)
public DatabaseSceneProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, int priority) : base(impl, providerGUID, assetInfo)
{
SceneMode = sceneMode;
_activateOnLoad = activateOnLoad;
_priority = priority;
}
public override void Update()
@ -76,10 +74,7 @@ namespace YooAsset
{
Progress = _asyncOp.progress;
if (_asyncOp.isDone)
{
if (SceneObject.IsValid() && _activateOnLoad)
SceneManager.SetActiveScene(SceneObject);
{
Status = SceneObject.IsValid() ? EStatus.Succeed : EStatus.Failed;
if (Status == EStatus.Failed)
{

View File

@ -455,13 +455,12 @@ namespace YooAsset
/// </summary>
/// <param name="location">场景的定位地址</param>
/// <param name="sceneMode">场景加载模式</param>
/// <param name="activateOnLoad">加载完毕时是否主动激活</param>
/// <param name="priority">优先级</param>
public SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
public SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, int priority = 100)
{
DebugCheckInitialize();
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
var handle = _assetSystemImpl.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority);
var handle = _assetSystemImpl.LoadSceneAsync(assetInfo, sceneMode, priority);
return handle;
}
@ -470,12 +469,11 @@ namespace YooAsset
/// </summary>
/// <param name="assetInfo">场景的资源信息</param>
/// <param name="sceneMode">场景加载模式</param>
/// <param name="activateOnLoad">加载完毕时是否主动激活</param>
/// <param name="priority">优先级</param>
public SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
public SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, int priority = 100)
{
DebugCheckInitialize();
var handle = _assetSystemImpl.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority);
var handle = _assetSystemImpl.LoadSceneAsync(assetInfo, sceneMode, priority);
return handle;
}
#endregion

View File

@ -128,12 +128,11 @@ namespace YooAsset
/// </summary>
/// <param name="location">场景的定位地址</param>
/// <param name="sceneMode">场景加载模式</param>
/// <param name="activateOnLoad">加载完毕时是否主动激活</param>
/// <param name="priority">优先级</param>
public static SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
public static SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, int priority = 100)
{
DebugCheckDefaultPackageValid();
return _defaultPackage.LoadSceneAsync(location, sceneMode, activateOnLoad, priority);
return _defaultPackage.LoadSceneAsync(location, sceneMode, priority);
}
/// <summary>
@ -141,12 +140,11 @@ namespace YooAsset
/// </summary>
/// <param name="assetInfo">场景的资源信息</param>
/// <param name="sceneMode">场景加载模式</param>
/// <param name="activateOnLoad">加载完毕时是否主动激活</param>
/// <param name="priority">优先级</param>
public static SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
public static SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, int priority = 100)
{
DebugCheckDefaultPackageValid();
return _defaultPackage.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority);
return _defaultPackage.LoadSceneAsync(assetInfo, sceneMode, priority);
}
#endregion