How to get function like ToString from custom Struct

I have a custom struct “FIntVector2D” and would like to add some of the functionality that the default “FVector” struct had.

This is what I have so far.
I don’t get any compiling errors, but in Unreal Blueprints I don’t get an option to convert to string.

.h

USTRUCT(immutable, noexport, BlueprintType)
struct FIntVector2D
{
	//GENERATED_USTRUCT_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IntVector2D", SaveGame)
		int32 X;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IntVector2D", SaveGame)
		int32 Y;

	FIntVector2D() {
		X = 0;
		Y = 0;
	}

	FIntVector2D(int32 inX, int32 inY) {
		X = inX;
		Y = inY;
	}

public:
	FString ToString() const;
	
 };

.cpp

#include "ObjectLib.h"

FString FIntVector2D::ToString() const
{
	return FString::Printf(TEXT("X=%d Y=%d"), X, Y);
}

The main problem and i think you already notice that considering you didn’t use UFUNCTION on that function, blueprints do not support struct functions, all operation on struct in blueprints are done via static functions in classes.

2nd-ly conversion is done via hardcoded behavior in blueprint graph shema code, there is way to plug in to it from objects by using right function names names (for example GetDisplayName() will be used in converion to string) but not sure about structs, i only breafly look at it, you might considering investigate more maybe you will find some hints what to do:

https://github.com/EpicGames/UnrealEngine/blob/a07fbf5ed73138b7af773a6acfbe1693a234b582/Engine/Source/Editor/BlueprintGraph/Private/EdGraphSchema_K2.cpp#L2258

You also need to know that autocasting (as code above names it) just automaticly adds function nodes, it’s not like it something special coded. Nothing will go wrong if you just function node that you can pick from node list, there many conversion functions that work that way and you also need to consider what NOTE in code i pointed above say:

// NOTE: Under no circumstances should anyone *ever* add a questionable cast to this function.
// If it could be at all confusing why a function is provided, to even a novice user, err on the side of do not cast!!!
// This includes things like string->int (does it do length, atoi, or what?) that would be autocasts in a traditional scripting language

To do easy to use conversion nodes, just make UObject class (by convention it should be UBlueprintFunctionLibrary but it will work from any class) and make static BlueprintPure (or Callable if you like) node functions. Static function makes node without “Target” pin, in C++ they are not part of object but only associated with it by namespace, in blueprint they work as independent nodes. Here you have blueprint math library if you want to see how such library is usally done, this file has all blueprint math nodes declered here:

https://github.com/EpicGames/UnrealEngine/blob/a27ad66f0a075f3b74ef8f68a4b2b0da4882425e/Engine/Source/Runtime/Engine/Classes/Kismet/KismetMathLibrary.h