1. Accessing UMG widgets which defined on the Blueprint child class
Solution: use meta=(BindWidget) UPROPERTY specifier when declaring the variable inside the C++ parent. Example: UPROPERTY(BlueprintReadOnly, meta = (BindWidget))
class UScaleBox* UI_BlockNameScaleBox;
|
2. Reading property from a Blueprint class
Solution: To do this, the handle toward the property need to be obtained using either FindField or FindFieldChecked and then actually read it using both the handle and the pointer to the instance. Example: FObjectProperty* prop=FindFieldChecked<FObjectProperty>(IDEWidgetClass, FName(TEXT("CloseButton")));
IDECloseButton=Cast<UButton>(prop->GetObjectPropertyValue(prop->ContainerPtrToValuePtr<UObject>(IDEWidgetHandle)));
|
3. Writing to property inside a Blueprint
Solution: Similar to reading the property, the handle toward the property need to be obtained using either FindField or FindFieldChecked and then actually write to it using both the handle and the pointer to the instance. Example: FStrProperty* prop = FindFieldChecked<FStrProperty>(IDEDialogClass, FName(TEXT("Title")));
prop->SetPropertyValue(prop->ContainerPtrToValuePtr<void*>(IDEDialogHandle), name /*some value*/);
|
4. Getting handle to the Blueprint class
To get the UClass* handle when the class name is known inside the constructor. Use the function ConstructorHelpers::FClassFinder<ClassName>
Example: static ConstructorHelpers::FClassFinder<UUserWidget> WidgetClassFinder(TEXT("/Game/UI/IDE/IDE.IDE_C"));
IDEWidgetClass = WidgetClassFinder.Class;
|