From 57b5efb6555bcd5c57aa3210243aee08dc148cf0 Mon Sep 17 00:00:00 2001 From: Carson Kompon Date: Wed, 17 Dec 2025 09:59:28 -0500 Subject: [PATCH] Only download packages from the current project when opening in the Editor (#3619) - Only download packages from the current project when opening in the editor - Make sure to download packages referenced within any libraries in the current project --- engine/Sandbox.Tools/StartupLoadProject.cs | 2 +- engine/Sandbox.Tools/Utility/CloudAsset.cs | 23 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/engine/Sandbox.Tools/StartupLoadProject.cs b/engine/Sandbox.Tools/StartupLoadProject.cs index 55f6a28d..c1b243c2 100644 --- a/engine/Sandbox.Tools/StartupLoadProject.cs +++ b/engine/Sandbox.Tools/StartupLoadProject.cs @@ -324,7 +324,7 @@ static class StartupLoadProject { var sw = Stopwatch.StartNew(); - packagesToDownload.AddRange( CloudAsset.GetAssetReferences( false ) ); + packagesToDownload.AddRange( CloudAsset.GetAssetReferences( true ) ); // 1. remove any installed packages we no longer need var required = new HashSet(); diff --git a/engine/Sandbox.Tools/Utility/CloudAsset.cs b/engine/Sandbox.Tools/Utility/CloudAsset.cs index 90c62f48..a4bac25e 100644 --- a/engine/Sandbox.Tools/Utility/CloudAsset.cs +++ b/engine/Sandbox.Tools/Utility/CloudAsset.cs @@ -280,7 +280,26 @@ public class CloudAsset string projectPath = Project.Current.GetAssetsPath().Replace( '\\', '/' ); var packages = new HashSet( StringComparer.OrdinalIgnoreCase ); - var gr = AssetSystem.All.Where( x => x.AssetType.IsGameResource && (!currentProjectOnly || x.AbsolutePath.StartsWith( projectPath, StringComparison.OrdinalIgnoreCase )) ); + HashSet validAssetPaths = null; + if ( currentProjectOnly ) + { + validAssetPaths = new HashSet( StringComparer.OrdinalIgnoreCase ); + + // Include current project + validAssetPaths.Add( projectPath ); + + // Include all libraries used by the current project + foreach ( var library in LibrarySystem.All ) + { + var libraryAssetsPath = library.Project.GetAssetsPath()?.Replace( '\\', '/' ); + if ( !string.IsNullOrEmpty( libraryAssetsPath ) ) + { + validAssetPaths.Add( libraryAssetsPath ); + } + } + } + + var gr = AssetSystem.All.Where( x => x.AssetType.IsGameResource && (!currentProjectOnly || validAssetPaths.Any( path => x.AbsolutePath.StartsWith( path, StringComparison.OrdinalIgnoreCase ) )) ); foreach ( var r in gr ) { string json = null; @@ -311,7 +330,7 @@ public class CloudAsset } } - var nativeResources = AssetSystem.All.Where( x => !x.AssetType.IsGameResource && (!currentProjectOnly || x.AbsolutePath.StartsWith( projectPath, StringComparison.OrdinalIgnoreCase )) ).ToArray(); + var nativeResources = AssetSystem.All.Where( x => !x.AssetType.IsGameResource && (!currentProjectOnly || validAssetPaths.Any( path => x.AbsolutePath.StartsWith( path, StringComparison.OrdinalIgnoreCase ) )) ).ToArray(); foreach ( var r in nativeResources ) { var config = r?.Publishing?.ProjectConfig;