BeginTransientXPropertyUpdate (Unreal Engine)

- Declaration

static UCavrnusLiveColorPropertyUpdate* BeginTransientColorPropertyUpdate(FCavrnusSpaceConnection SpaceConnection, const FPropertiesContainer& ContainerName, const FString& PropertyName, FLinearColor PropertyValue);

static UCavrnusLiveBoolPropertyUpdate* BeginTransientBoolPropertyUpdate(FCavrnusSpaceConnection SpaceConnection, const FPropertiesContainer& ContainerName, const FString& PropertyName, bool PropertyValue);

static UCavrnusLiveFloatPropertyUpdate* BeginTransientFloatPropertyUpdate(FCavrnusSpaceConnection SpaceConnection, const FPropertiesContainer& ContainerName, const FString& PropertyName, float PropertyValue);

static UCavrnusLiveStringPropertyUpdate* BeginTransientStringPropertyUpdate(FCavrnusSpaceConnection SpaceConnection, const FPropertiesContainer& ContainerName, const FString& PropertyName, FString PropertyValue);

static UCavrnusLiveVectorPropertyUpdate* BeginTransientVectorPropertyUpdate(FCavrnusSpaceConnection SpaceConnection, const FPropertiesContainer& ContainerName, const FString& PropertyName, FVector4 PropertyValue);

static UCavrnusLiveTransformPropertyUpdate* BeginTransientTransformPropertyUpdate(FCavrnusSpaceConnection SpaceConnection, const FPropertiesContainer& ContainerName, const FString& PropertyName, FTransform PropertyValue);

- Description

Begins a temporary property update. See Documentation on UCavrnusLiveXPropertyUpdate(TODO: LINK) for additional details.

Transient property updates are not saved to the Cavrnus Journal, and will not persist once everyone has left the scene. They will, however, show properly for anyone currently in the space or anyone new who joins.

The reason to do this as opposed to PostXPropertyUpdate is to reduce the size of your journal. Sometimes an interaction like dragging an object or color wheel will produce dozens or hundreds of “changes” to a property before the interaction is complete. While you will want remote users to see all of these changes, having them all individually saved to your journal is wasteful. Therefore, a UCavrnusLiveXPropertyUpdate(TODO: LINK) allows you to send those changes to other users while only saving the final value to the server.

If you are only making a single change to a property (ex: pushing a button) then PostXPropertyUpdate is preferable.

- Blueprint Sample

 

TransientTransform.png
Transient Updater

- Code Sample

A slider adjusts the something visible in the scene, (e.g. brightness of a light, scale of an object, etc.) but isn’t written to the journal permanently until the user hits the Save button.

PropertySliderWidget.h:

#pragma once #include "CoreMinimal.h" #include "Blueprint/UserWidget.h" #include "Components/Button.h" #include "Components/Slider.h" #include "PropertySliderWidget.generated.h" class UCavrnusLiveFloatPropertyUpdate; UCLASS() class MODULE_API UPropertySliderWidget : public UUserWidget { GENERATED_BODY() public: void NativeConstruct(); private: void OnSliderValueChanged(float Value); void OnSaveButtonReleased(); void OnCancelButtonReleased(); UPROPERTY(BlueprintReadWrite, meta = (bindWidget)) Button* SaveButton = nullptr; UPROPERTY(BlueprintReadWrite, meta = (bindWidget)) Button* CancelButton = nullptr; UPROPERTY(BlueprintReadWrite, meta = (bindWidget)) Slider* ValueSlider = nullptr; UPROPERTY() UCavrnusLiveFloatPropertyUpdate* ValuePropertyUpdater; // PropertyContainerName and PropertyName will match the object's property settings. The object would be bound to the property independently (i.e. the slider does not modify the object directly) FString PropertyContainerName; FString PropertyName; FCavrnusSpaceConnection SpaceConnection; float SavedValue; float CurrentValue; };

PropertySlider.cpp:

#include "PropertySliderWidget.h" #include "CavrnusFunctionLibrary.h" #include "Types/CavrnusLiveFloatPropertyUpdate.h" void UPropertySliderWidget::NativeConstruct() { Super::NativeConstruct(); CurrentValue = SavedValue = UCavrnusFunctionLibrary::GetFloatPropertyValue(SpaceConnection, PropertyContainerName, PropertyName); if (SaveButton) { SaveButton->OnReleased.BindUFunction(this, GET_FUNCTION_NAME_CHECKED(UPropertySliderWidget, OnSaveButtonReleased)); } if (CancelButton) { CancelButton->OnReleased.BindUFunction(this, GET_FUNCTION_NAME_CHECKED(UPropertySliderWidget, OnCancelButtonReleased)); } if (ValueSlider) { ValueSlider->Value = CurrentValue; ValueSlider->OnValueChanged.BindUFunction(this, GET_FUNCTION_NAME_CHECKED(UPropertySliderWidget, OnSliderValueChanged)); } } void UPropertySliderWidget::OnSaveButtonReleased() { SavedValue = CurrentValue; if (ValuePropertyUpdater) { ValuePropertyUpdater->Finalize(CurrentValue); ValuePropertyUpdater = nullptr; } } void UPropertySliderWidget::OnCancelButtonReleased() { CurrentValue = SavedValue; if (ValueSlider) { ValueSlider->Value = SavedValue; } if (ValuePropertyUpdater) { ValuePropertyUpdater->Cancel(); ValuePropertyUpdater = nullptr; } } void UPropertySliderWidget::OnSliderValueChanged(float Value) { CurrentValue = Value; if (ValuePropertyUpdater) { ValuePropertyUpdater->UpdateWithNewData(Value) } else { ValuePropertyUpdater = UCavrnusFunctionLibrary::BeginTransientFloatPropertyUpdate(SpaceConnection, PropertyContainerName, PropertyName, Value); } }

Related pages