From 90d8842f067e2344410af38cd0562a5301458ced Mon Sep 17 00:00:00 2001 From: hevinci Date: Tue, 27 Jun 2023 15:04:47 +0800 Subject: [PATCH] update runtime code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 移除了LoadSceneAsync方法里的activateOnLoad参数 --- Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs | 6 +++--- .../AssetSystem/Handles/SceneOperationHandle.cs | 4 ++-- .../AssetSystem/Provider/BundledSceneProvider.cs | 7 +------ .../AssetSystem/Provider/DatabaseSceneProvider.cs | 9 ++------- .../YooAsset/Runtime/PackageSystem/ResourcePackage.cs | 10 ++++------ Assets/YooAsset/Runtime/YooAssetsExtension.cs | 10 ++++------ 6 files changed, 16 insertions(+), 30 deletions(-) diff --git a/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs b/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs index e65c437..defe8ba 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs @@ -147,7 +147,7 @@ namespace YooAsset /// /// 加载场景 /// - public SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode, bool activateOnLoad, int priority) + public SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode, int priority) { if (assetInfo.IsInvalid) { @@ -168,9 +168,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); diff --git a/Assets/YooAsset/Runtime/AssetSystem/Handles/SceneOperationHandle.cs b/Assets/YooAsset/Runtime/AssetSystem/Handles/SceneOperationHandle.cs index 4f15206..b170a08 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Handles/SceneOperationHandle.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Handles/SceneOperationHandle.cs @@ -3,7 +3,7 @@ namespace YooAsset { public class SceneOperationHandle : OperationHandleBase - { + { private System.Action _callback; internal string PackageName { set; get; } @@ -51,7 +51,7 @@ namespace YooAsset } /// - /// 激活场景 + /// 激活场景(当同时存在多个场景时用于切换激活场景) /// public bool ActivateScene() { diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSceneProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSceneProvider.cs index b8e4d6b..85ce68b 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSceneProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSceneProvider.cs @@ -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) { diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSceneProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSceneProvider.cs index 48b9497..23e2cab 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSceneProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSceneProvider.cs @@ -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) { diff --git a/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs b/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs index ce843e7..ebc843f 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs @@ -455,13 +455,12 @@ namespace YooAsset /// /// 场景的定位地址 /// 场景加载模式 - /// 加载完毕时是否主动激活 /// 优先级 - 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 /// /// 场景的资源信息 /// 场景加载模式 - /// 加载完毕时是否主动激活 /// 优先级 - 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 diff --git a/Assets/YooAsset/Runtime/YooAssetsExtension.cs b/Assets/YooAsset/Runtime/YooAssetsExtension.cs index 3ec457a..3cb0941 100644 --- a/Assets/YooAsset/Runtime/YooAssetsExtension.cs +++ b/Assets/YooAsset/Runtime/YooAssetsExtension.cs @@ -128,12 +128,11 @@ namespace YooAsset /// /// 场景的定位地址 /// 场景加载模式 - /// 加载完毕时是否主动激活 /// 优先级 - 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); } /// @@ -141,12 +140,11 @@ namespace YooAsset /// /// 场景的资源信息 /// 场景加载模式 - /// 加载完毕时是否主动激活 /// 优先级 - 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