Hi!
I faced an issue working with subsystems.
I have a simple c++ subsystem UMyGameInstanceSubsystemCpp, with one simple function declaration GetMyString:
#pragma once
#include "CoreMinimal.h"
#include "Subsystems/GameInstanceSubsystem.h"
#include "MyGameInstanceSubsystemCpp.generated.h"
UCLASS(DisplayName = "CppSubsystem", Blueprintable)
class SUBSYSTEMTEST_API UMyGameInstanceSubsystemCpp : public UGameInstanceSubsystem
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "MyCategory")
FString GetMyString() const;
};
Then I am creating a new Blueprint class BP_MyGameInstanceSubsystem derived from UMyGameInstanceSubsystemCpp, and implementing this single function:
And finally I have one dummy actor BP_DummyActor on scene which calls this function GetMyString on BeginPlay:
It works as intended if I am testing in SelectedViewport or NewEditorWindow(PIE):
It prints pre-call message, print message inside subsystem function, prints function return result and then post-call message.
But when I am trying to test in Standalone - it doesn’t work well:
It prints pre-call and post-call messages, but function doesn’t get called. Instead it prints default function return value (empty string) and internal print doesn’t get called.
And one more strange thing: it doesn’t work in shipment build of this test project, but works in shipment build of our main project.
Git repository of test project: Git repository
Could anyone help me with this issue? I want to make it work in every case, or to understand that I am doing wrong and why it is impossible.
Thank you!
UPDATE & SOLUTION
TLDR:
The subsystem was not being picked up properly for asset scan. This was solved by going “Project Settings” → “Game” → “Asset Manager”, then adding a new entry to the Primary Asset Types To Scan
. Just referencing the asset seemed to do the trick for me.
Full post: Subsystem function call failure - #5 by YB_Wertolet