Nyhillius
(Nyhillius)
1
Hello,
To simplify my project, I need to create a structure or a class with operators.
For example the operator : MyStruct operator+(int Value) const;
I’am programmer, I know how to make an overload operator in a cpp file but I have not found how to make blueprint callable overload operators.
I searched a lot on Google, I even watched how the vector structure was made but nothing works.
Please somebody help me !
Tanks a lot.
Nyhillius
(Nyhillius)
2
I can add a snippet of code.
#pragma once
#include "Object.h"
#include "ProgressFraction.generated.h"
/**
*
*/
UCLASS(BlueprintType)
class UNDEADSTATE_API UProgressFraction : public UObject
{
GENERATED_BODY()
public:
UProgressFraction();
UProgressFraction(int Current, int Max);
/* Operators */
FORCEINLINE UProgressFraction operator+(const UProgressFraction& F) const;
FORCEINLINE UProgressFraction operator+(int Value) const;
/* Displaying */
UFUNCTION(BlueprintCallable, Category = "Displaying")
void Dump() const;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Meta = (ExposeOnSpawn = true))
int Current;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Meta = (ExposeOnSpawn = true))
int Max;
};
FORCEINLINE UProgressFraction UProgressFraction::operator+(const UProgressFraction& F) const
{
return UProgressFraction(Current + F.Current, Max);
}
FORCEINLINE UProgressFraction UProgressFraction::operator+(int Value) const
{
return UProgressFraction(Current + Value, Max);
}