Support UE 5.7

This commit is contained in:
Eragon-Brisingr
2026-07-07 13:07:53 +08:00
parent 2bf500bd98
commit 49b04addb4
8 changed files with 198 additions and 13 deletions

View File

@@ -6,6 +6,7 @@
#include "MaterialShared.h"
#include "Materials/Material.h"
#include "Misc/CoreDelegates.h"
#include "Misc/EngineVersionComparison.h"
#include "Misc/Paths.h"
#include "Modules/ModuleManager.h"
#include "ShaderCore.h"
@@ -16,6 +17,15 @@
#include "ShaderLabModel.h"
#include "UObject/UObjectIterator.h"
// FCoreDelegates::OnPostEngineInit became the accessor GetOnPostEngineInit() in UE 5.8; 5.7 exposes the
// delegate member directly. Mirror the same bridge the runtime subsystem uses so the shared plugin builds
// on both engines.
#if UE_VERSION_OLDER_THAN(5, 8, 0)
#define SHADERLAB_ON_POST_ENGINE_INIT FCoreDelegates::OnPostEngineInit
#else
#define SHADERLAB_ON_POST_ENGINE_INIT FCoreDelegates::GetOnPostEngineInit()
#endif
DEFINE_LOG_CATEGORY_STATIC(LogShaderLabBuilder, Log, All);
namespace
@@ -154,7 +164,7 @@ public:
// (a fresh clone lacks .vscode — it is git-ignored). Deferred to post-engine-init so shader-source
// mappings (added above) and UMaterial reflection are ready; the callback self-gates to an interactive
// editor session (no cook / -game / commandlet / unattended).
PostEngineInitHandle = FCoreDelegates::GetOnPostEngineInit().AddStatic(&ShaderLabIDE_EnsureGeneratedIfMissing);
PostEngineInitHandle = SHADERLAB_ON_POST_ENGINE_INIT.AddStatic(&ShaderLabIDE_EnsureGeneratedIfMissing);
UE_LOG(LogShaderLabBuilder, Log, TEXT("ShaderLabBuilder module started."));
}
@@ -168,7 +178,7 @@ public:
}
if (PostEngineInitHandle.IsValid())
{
FCoreDelegates::GetOnPostEngineInit().Remove(PostEngineInitHandle);
SHADERLAB_ON_POST_ENGINE_INIT.Remove(PostEngineInitHandle);
PostEngineInitHandle.Reset();
}
}