GetXPropertyValue (Unreal Engine)

- Declaration

static FLinearColor GetColorPropertyValue(FCavrnusSpaceConnection SpaceConnection, const FPropertiesContainer& ContainerName, const FString& PropertyName);

static bool GetBoolPropertyValue(FCavrnusSpaceConnection SpaceConnection, const FPropertiesContainer& ContainerName, const FString& PropertyName);

static float GetFloatPropertyValue(FCavrnusSpaceConnection SpaceConnection, const FPropertiesContainer& ContainerName, const FString& PropertyName);

static FString GetStringPropertyValue(FCavrnusSpaceConnection SpaceConnection, const FPropertiesContainer& ContainerName, const FString& PropertyName);

static FVector4 GetVectorPropertyValue(FCavrnusSpaceConnection SpaceConnection, const FPropertiesContainer& ContainerName, const FString& PropertyName);

static FTransform GetTransformPropertyValue(FCavrnusSpaceConnection SpaceConnection, const FPropertiesContainer& ContainerName, const FString& PropertyName);

- Description

Gets the current property value.

This provides a snapshot of the current Property value. This may return a default value as defined by DefineXPropertyDefaultValue, a value that has been posted by a user using PostXPropertyUpdate, or empty default data if neither of the former is present.

Note that while it is sometimes useful to get the current value, a more common use case is to call BindXPropertyValue which will give you an event any time the property value changes. This is a more efficient way of keeping your scene objects up-to-date with the server than, say calling GetXPropertyValue every frame.

- Blueprint Sample

 

GetPropertyValue.png
GetColorPropertyValue

- Code Sample

Example case - color and height of a flag.

FlagActor.h:

#include "GameFramework/Actor.h" #include "Types/CavrnusSpaceConnection.h" #include "FlagActor.generated.h" class UMaterialInstanceDynamic; UCLASS() class MODULE_API AFlagActor : public AActor { GENERATED_BODY() public: virtual void Tick( float DeltaSeconds ) override; UFUNCTION(BlueprintImplementableEvent) void OnFlagHeightChanged(); private: UPROPERTY() LinearColor FlagColor; UPROPERTY() float FlagHeight; UMaterialInstanceDynamic* FlagFabricMaterial; // Objects that synchronize properties should be created using UCavrnusFunctionLibrary::SpawnObject. This gives the spawner back the properties container name that this object will use in the journal. FString ContainerName; FCavrnusSpaceConnection SpaceConnection; };

FlagActor.cpp

#include "FlagActor.h" #include "CavrnusFunctionLibrary.h" #include "Materials/MaterialInstanceDynamic.h" void AFlagActor::Tick( float DeltaSeconds ) { Super::Tick(DeltaSeconds); float NewFlagHeight = UCavrnusFunctionLibrary::GetFloatPropertyValue(SpaceConnection, ContainerName, "FlagHeight"); if (NewFlagHeight != FlagHeight) { FlagHeight = NewFlagHeight; OnFlagHeightChanged(); } LinearColor NewFlagColor = UCavrnusFunctionLibrary::GetColorPropertyValue(SpaceConnection, ContainerName, "FlagColor"); if (NewFlagColor!= FlagColor) { FlagColor = NewFlagColor; if (FlagFabricMaterial != nullptr && FlagFabricMaterial->IsValidLowLevel()) { FlagFabricMaterial->SetVectorParameterValue(TEXT("Color"), FlagColor); } }

Related pages