Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Current »

- Declaration

static void DefineColorPropertyDefaultValue(FCavrnusSpaceConnection SpaceConnection, FString ContainerName, FString PropertyName, FLinearColor PropertyValue);

static void DefineBoolPropertyDefaultValue(FCavrnusSpaceConnection SpaceConnection, FString ContainerName, FString PropertyName, bool PropertyValue);

static void DefineFloatPropertyDefaultValue(FCavrnusSpaceConnection SpaceConnection, FString ContainerName, FString PropertyName, float PropertyValue);

static void DefineStringPropertyDefaultValue(FCavrnusSpaceConnection SpaceConnection, FString ContainerName, FString PropertyName, FString PropertyValue);

static void DefineVectorPropertyDefaultValue(FCavrnusSpaceConnection SpaceConnection, FString ContainerName, FString PropertyName, FVector4 PropertyValue);

static void DefineTransformPropertyDefaultValue(FCavrnusSpaceConnection SpaceConnection, FString ContainerName, FString PropertyName, FTransform PropertyValue);

- Description

Defines what the application will show if a new prop value has not been assigned.

This default is useful for when you call Bind for objects that already have an existing “state” built into your application. Binding to a property with no defined Default and no property assignments yet value will give you blank data (Color[0,0,0,0], etc) as its initial state. This would result in things like the transforms of built-in objects jumping to the scene origin as soon as they Bind their transform property. DefineXPropertyDefaultValue prevents this.

Once an update has been posted to the journal for this property value the default becomes irrelevant.

- Blueprint Sample

DefineDefaultValue.png

- Code Sample

Example case - color and height of a flag.

FlagActor.h

#include "GameFramework/Actor.h"
#include "Types/CavrnusSpaceConnection.h"
#include "FlagActor.generated.h"

UCLASS()
class MODULE_API AFlagActor : public AActor
{
  GENERATED_BODY()
  
public:
  void InitializeProperties(FString& InContainerName, FCavrnusSpaceConnection& InSpaceConnection);
  
private:
  UPROPERTY()
  LinearColor FlagColor;
  
  UPROPERTY()
  float FlagHeight;
  
  // 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"

void AFlagActor::InitializeProperties(FString& InContainerName, FCavrnusSpaceConnection& InSpaceConnection)
{
  ContainerName = InContainerName;
  SpaceConnection = InSpaceConnection;
  
  UCavrnusFunctionLibrary::DefineColorPropertyDefaultValue(InSpaceConnection, InContainerName, "FlagColor", FlagColor);
  UCavrnusFunctionLibrary::DefineFloatPropertyDefaultValue(InSpaceConnection, InContainerName, "FlagHeight", FlagHeight);
}
  • No labels