C++; Widget not getting visible when calling parent's SetActorHiddenInGame(false)
In the constructor of my class (let's call it "Menu"), derived from Actor, I create the following widget:
menuWidget = CreateDefaultSubobject(TEXT("Widget"));
In the editor, in the BP derived from this class (lets call it "BP_widget"), I set the class of the widget. For testing purposes, I also add a cube and a another widget (lets call it "secondWidget") as children of the widget created by code. The "menuWidget" and the "secondWidget" have the same rotation and everything else. All components (the "menuWidget", the cube and the "secondWidget") are visible in the editor. If I add the "BP_widget" manually to the level using the editor, they are all visible correctly during the gameplay.
At BeginPlay in the "BP_pawn" I initialize an object of the type "BP_widget" (let's call it "widgetObj" and call "widgetObj->SetActorHiddenInGame(true)".
On trigger button event in "BP_pawn" I call "widgetObj->SetActorHiddenInGame(false)" (calling tested both in code and in BP). This sets all (cube and "secondWidget") components except the "menuWidget" to visible.
I found that after removing the line "menuWidget->RegisterComponent();" from my code from above, the "menuWidget" will be set to visible correctly and all the components will be visible.
Follow this question
Once you sign in you will be able to subscribe for any updates here