Fix -Game no matieral error

This commit is contained in:
Eragon-Brisingr
2026-07-05 11:26:32 +08:00
parent 799848f87f
commit a6fbdf10f8
30 changed files with 331 additions and 206 deletions

View File

@@ -8,7 +8,7 @@
#include "MaterialEditorModule.h"
#include "Misc/Paths.h"
#include "Modules/ModuleManager.h"
#include "ShaderCore.h"
#include "ShaderLabGraphBuilder.h"
#include "ShaderLabMaterialInstanceConstant.h"
#include "Styling/AppStyle.h"
#include "Textures/SlateIcon.h"
@@ -22,21 +22,16 @@ namespace ShaderLabVSCodeButton
{
static FDelegateHandle GExtenderDelegateHandle;
/** Reverse the ShaderLabPath virtual path (e.g. "/Project/Examples/Basic.usl") to a disk path via the
* registered shader mappings (generic — /Project, /Plugin/<any>, /Engine). Empty if unresolved. */
/** Reverse the ShaderLabPath virtual path (e.g. "/Project/Examples/Basic.usl") to an absolute disk path
* via the shared shader-mapping resolver (generic — /Project, /Plugin/<any>, /Engine). Empty if unresolved. */
static FString ResolveVirtualToDisk(const FString& VirtualPath)
{
int32 BestKeyLen = -1;
FString BestDisk;
for (const TPair<FString, FString>& Mapping : AllShaderSourceDirectoryMappings())
FString Disk;
if (!FShaderLabGraphBuilder::ResolveVirtualShaderFile(VirtualPath, Disk))
{
if (VirtualPath.StartsWith(Mapping.Key + TEXT("/"), ESearchCase::IgnoreCase) && Mapping.Key.Len() > BestKeyLen)
{
BestKeyLen = Mapping.Key.Len();
BestDisk = Mapping.Value / VirtualPath.RightChop(Mapping.Key.Len() + 1);
}
return FString();
}
return (BestKeyLen >= 0) ? FPaths::ConvertRelativePathToFull(BestDisk) : FString();
return FPaths::ConvertRelativePathToFull(Disk);
}
static void OpenInVSCode(TWeakObjectPtr<UShaderLabMaterialInstanceConstant> MICWeak)