Hi Unavi,
I’ve got good news for you, C# property style accessors are coming in 4.17, though only declared from C++ for now (and they won’t work in interfaces since there is still a backing variable that is used to store the metadata). Here’s an example of usage:
private:
UPROPERTY(EditAnywhere, BlueprintSetter=ApplySkin)
UCharacterSkinDescription* ActiveSkin;
public:
UFUNCTION(BlueprintSetter)
void ApplySkin(UCharacterSkinDescription* InSkin)
{
if (InSkin != ActiveSkin)
{
ActiveSkin = InSkin;
USkeletalMeshComponent* MyMeshComponent = GetMesh();
MyMeshComponent->SetSkeletalMesh(ActiveSkin ? ActiveSkin->Mesh : nullptr);
MyMeshComponent->OverrideMaterials.Reset();
if (ActiveSkin != nullptr)
{
for (int32 Index = 0; Index < ActiveSkin->Materials.Num(); ++Index)
{
MyMeshComponent->SetMaterial(Index, ActiveSkin->Materials[Index]);
}
}
}
}
This will show up as a regular variable that can be read or set in a BP, but setting it calls the method instead.
Cheers,
Michael Noland
Wow another huge win for blueprint component creation! Thanks so much! I can’t tell you how many times I’ve refactored code after I realized a variable change needs to trigger a UI event, which can be solved in seconds with a setter.