Skip to content

[Blueprint Only] Setting a FObjectProperty with FieldNotify from Blueprint doesnt broadcast changes as others do. #78

@jmgomez

Description

@jmgomez

Setting a FObjectProperty with FieldNotify from Blueprint doesnt broadcast changes as others do.

The following code works as expected:

uClass UPlaceableViewModel of UMVVMViewModelBase:
  (BlueprintType)
  uprops(BlueprintReadWrite, EditAnywhere, FieldNotify):
    selectedName: FText
    total: int32
    bIsVisible: bool
    selectedIcon: UTexture2DPtr

  proc update*(selected: USolDataAssetPtr, items: TArray[USolDataAssetPtr], idx: int32) =
    if selected.isNotNil:
      self.selectedName = selected.getName().toText()
      self.selectedIcon = selected.icon
    self.total = items.num
    self.bIsVisible = items.num > 0

However, when setting the prop selectedIcon from blueprints it doesnt notify the change (it does from others).

See the code that handles it (it gets injected in the class constructor)

proc genFieldNotifySetterAssignment(field: UEField): NimNode = 
  let setterName = ident field.name & "Setter"
  genAst(propName = newLit field.name, setterName, propType = ident field.uePropType):
    let prop = self.getClass.getFPropertyByName(propName)
    when not propType is UObjectPtr: #UObjectPtr setters has issues
      prop.setSetter(setterName)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions