-
Notifications
You must be signed in to change notification settings - Fork 33
Description
I tried to bind the MetasoundEngine to get access to UMetaSoundBuilderSubsystem's CreateSourcePresetBuilder here: Engine\Plugins\Runtime\Metasound\Source\MetasoundEngine\Public\MetasoundBuilderSubsystem.h:
UFUNCTION(BlueprintCallable, Category = "Audio|MetaSound|Builder", meta = (ExpandEnumAsExecs = "OutResult"))
UPARAM(DisplayName = "Source Preset Builder") UMetaSoundSourceBuilder* CreateSourcePresetBuilder(FName BuilderName, const TScriptInterface<IMetaSoundDocumentInterface>& ReferencedSourceClass, EMetaSoundBuilderResult& OutResult);
It should be as simple as adding MetasoundEngine to the game.json's extraBpModuleNames entry and regenerating the bindings but when examining the bindings it's missing.
The ReferencedSourceClass paramenter is suspicious because of TScriptInterface. All the functions using TScriptInterface are missing from the generated bindings. We were suspecting it might have something to do with the parameter being a const ref because Nim doesn't have a way to define something as const ref like in C++, but FindBuilderOfDocument is also missing.
// Returns the builder associated with the given MetaSound (if one exists, transient or asset).
UFUNCTION(BlueprintCallable, Category = "Audio|MetaSound|Builder", meta = (DisplayName = "Find Builder By MetaSound"))
UPARAM(DisplayName = "Builder") UMetaSoundBuilderBase* FindBuilderOfDocument(TScriptInterface<const IMetaSoundDocumentInterface> InMetaSound) const;The workaround and probably the correct way of dealing with I-class interfaces is to do PCH bindings for types see ##92. For example:
game.json:
{
"extraModuleNames": ["MetasoundEngine", "MetasoundFrontend", "MetasoundEditor"],
"enginePluginsByPath": ["Runtime/Metasound"]
}nuegame.h:
#include "MetasoundBuilderSubsystem.h" // for Engine\Plugins\Runtime\Metasound\Source\MetasoundEngine\Public\MetasoundBuilderSubsystem.hThen in your nim code:
#bind the I class of the interface
type
IMetaSoundDocumentInterface* {.importcpp.} = object
IMetaSoundDocumentInterfacePtr* = ptr IMetaSoundDocumentInterface
#manual binding of missing API
proc createSourcePresetBuilder(sys: UMetaSoundBuilderSubsystemPtr, builderName:FName, referencedSourceClass: TScriptInterface[IMetaSoundDocumentInterface], outResult: var EMetaSoundBuilderResult): UMetaSoundSourceBuilderPtr {.importcpp:"#->CreateSourcePresetBuilder(@)".}
#example of TScriptInterface and API usage
uClass USolAudioDirWatcherSubsystem of UEngineSubsystem:
ufuncs:
proc createMetasoundAsset(filePath: FString) =
#...
let msTemplate = loadObject[UObject](nil, "/Game/Audio/MetasoundSourceTemplates/MS_SFX_Mono_OneShot_Template.MS_SFX_Mono_OneShot_Template")
let tscript = makeTScriptInterface[IMetaSoundDocumentInterface](msTemplate)
var status: EMetaSoundBuilderResult
let ssbuilder: UMetaSoundSourceBuilderPtr = msbsys.createSourcePresetBuilder(n "SFXBuilder", tscript, status)
if status == Succeeded:
log "created the source preset builder"