Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jmgomez opened this issue Aug 21, 2024 · 0 comments

Comments

@jmgomez
Copy link
Owner

jmgomez commented Aug 21, 2024

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant