Page 1 of 1

How to notify array add changed in UE4 C++ code

Posted: 12 Apr 2018, 05:49
by ride_wind
Hi,

I create ViewModel using c++ code, and can use "UNoesisFunctionLibrary::NotifyChanged(this, IsTestName);" to notify property changed.

How to notify array add changed?

Thanks.

Re: How to notify array add changed in UE4 C++ code

Posted: 12 Apr 2018, 10:48
by hcpizzi
You can use UNoesisFunctionLibrary::NotifyArrayChanged in much the same way, but that function is very coarse and not optimal.

NoesisTypeClass.h exposes more fine grained functions you can use. In your case, you want to use NoesisNotifyArrayPropertyAdd. The way to use it is that you pass the address of the array, like this:
UCLASS()
class UMyClass : public UObject
{
  UPROPERTY(BlueprintReadWrite)
  TArray<SomeType> MyArray;

  void AddSomething()
  {
    MyArray.Add(Something);
    NoesisNotifyArrayPropertyAdd(&MyArray);
  }
};