Hi!
I’m trying to make a property like this:
UCLASS()
class WARGAME_API ABuildingSlot : public AActor {
...
...
ABuildingSlot(const FObjectInitializer& ObjectInitializer);
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "UI")
TSubclassOf< UUserWidget > UIWidgetClass;
private:
UWidgetComponent *widget; // Should have an instance of the
// blueprint specified class as an UWidgetComponent
void rotatewg();
}
And then i have a blueprint “A” that have ABuildingSlot as it’s parent.
Then if i open the “Defaults” for blueprint A, I can change the UIWidgetClass to my widget “wgSlotAB”.
Ok, but now how do i spawn an WidgetComponent ( UE 4.6 ) using that type from C++ code?
Is it possible to spawn that on the ABuildingSlot constructor? I’m not sure if the FObjectInitializer inits that property or not…
Is there a way that after i set the blueprint for the UIWidgetClass the engine automatically spawns the component for me?
If possible, i want my widget variable to receive the instance in a way that i just have to specify the blueprint on the “Defaults”.
After that i would like to transform the widgetcomponent, for example, on the function rotatewg() at some time in the future by acessing the widget.
Thanks.
=]