Menu-in-editor fixes 2 (#3395)

* Skip menu editor code outside of the menu project
* Asset Browser: skip menu project assets in Everything and Recents
This commit is contained in:
Sol Williams
2025-11-24 15:20:04 +00:00
committed by GitHub
parent 5e8a352de6
commit aff86e3ad2
3 changed files with 20 additions and 5 deletions

View File

@@ -21,7 +21,7 @@ public partial class Project
int lastCompilerHash;
// anything that means we need to re-create the compiler and recompile should be here
int CompilerHash => HashCode.Combine( Active, Json.SerializeAsObject( Config.GetCompileSettings() ).ToJsonString(), Config.IsStandaloneOnly, Config.Org, Config.Ident, Config.Type, string.Join( ";", PackageReferences() ) );
int CompilerHash => HashCode.Combine( Active, Current == this, Json.SerializeAsObject( Config.GetCompileSettings() ).ToJsonString(), Config.IsStandaloneOnly, Config.Org, Config.Ident, Config.Type, string.Join( ";", PackageReferences() ) );
/// <summary>
/// These package types should reference package.base
@@ -173,6 +173,10 @@ public partial class Project
if ( !Active )
return;
// only want menu editor code if we're in the menu project
if ( this != Current && Config.Ident == "menu" )
return;
if ( !HasEditorPath() )
return;

View File

@@ -18,16 +18,18 @@ public record EverythingLocation : LocalAssetBrowser.Location
{
string projectPath = Project.Current.GetAssetsPath().NormalizeFilename( false );
var menuProject = EditorUtility.Projects.GetAll().FirstOrDefault( x => x.Config.Ident == "menu" );
string menuPath = menuProject?.GetAssetsPath().NormalizeFilename( false );
foreach ( var asset in AssetSystem.All.OrderBy( x => x.Name ) )
{
bool isCloud = asset.AbsolutePath.Contains( ".sbox/cloud/" );
if ( isCloud ) continue;
if ( asset.AbsolutePath.StartsWith( "mount:" ) )
if ( menuPath is not null && menuProject != Project.Current )
{
yield return new FileInfo( asset.AbsolutePath );
continue;
bool isMenu = asset.AbsolutePath.StartsWith( menuPath );
if ( isMenu ) continue;
}
yield return new FileInfo( asset.AbsolutePath );

View File

@@ -16,8 +16,17 @@ public record RecentsLocation : LocalAssetBrowser.Location
public override IEnumerable<FileInfo> GetFiles()
{
var menuProject = EditorUtility.Projects.GetAll().FirstOrDefault( x => x.Config.Ident == "menu" );
string menuPath = menuProject?.GetAssetsPath().NormalizeFilename( false );
foreach ( var asset in AssetSystem.All.OrderByDescending( x => x.LastOpened ).Take( 50 ) )
{
if ( menuPath is not null && menuProject != Project.Current )
{
bool isMenu = asset.AbsolutePath.StartsWith( menuPath );
if ( isMenu ) continue;
}
yield return new FileInfo( asset.AbsolutePath );
}
}