-1

I a trying to create a set of structs using TSet, however, when I compile I get the error:

The structure X is used in a TSet but does not have a GetValueTypeHash defined

How do I implement a GetValueTypeHash definition in my struct?

USTRUCT(BlueprintType)
struct Fpiece
{
    GENERATED_BODY()
        // Use UPROPERTY() to decorate member variables as they allow for easier integration with network replication as well as potential garbage collection processing
    UPROPERTY(BlueprintReadOnly, Category = Tutorial) int color;
    UPROPERTY(BlueprintReadOnly, Category = Tutorial) int man;
    UPROPERTY(BlueprintReadOnly, Category = Tutorial) int locationX;
    UPROPERTY(BlueprintReadOnly, Category = Tutorial) int locationY;
    UPROPERTY(BlueprintReadOnly, Category = Tutorial) int point;

};

and in public constructor:

UPROPERTY(BlueprintReadOnly, Category = Tutorial) TSet<Fpiece> pieces;
Carl Newman
  • 11
  • 1
  • 3
  • Without knowing what your structure `X` is, it will be hard to tell what's the possibly best implementation for `GetValueTypeHash()` actually is. – πάντα ῥεῖ Jul 26 '22 at 15:00

1 Answers1

0

Add the following code to your solution:

USTRUCT()
struct Fpiece
{
    GENERATED_BODY()
    int32 SomeData = 0;
};

and then implement like this:

uint32 GetTypeHash(const Fpiece& other);
{
    return FCrc::MemCrc32(&other, sizeof(Fpiece));
}
Carl Newman
  • 11
  • 1
  • 3