Download

Can you pass custom Struct declared as UStruct() to an Actor function declared as UFunction() ?

So im trying to create a struct defined as Ustruct


USTRUCT()
struct FVoxelTerrainParams
{
    GENERATED_USTRUCT_BODY()

    FVoxelTerrainParams()
    {

    }
    FVoxelTerrainParams(const FVoxelTerrainParams &p) {
        set(p);
    }
    void set(const FVoxelTerrainParams &p)
    {

    }
    //UPROPERTY()
    float chunks_Size = 50.f;
}

but when i pass it to function


UFUNCTION(Category = "Voxel Terrain", BlueprintCallable)
    void update_terrain(FVoxelTerrainParams params)
    {
        Params = p;
    };

I get an error

So. Can you actually do it or you have to make it UObject child?

USTRUCT(BlueprintType)
struct FVoxelTerrainParams
{

I’ve Tried it. Nothing changes. Its so weard

I have this error

and i think it stops compiler from parsing code further. It doesn’t show me all errors that i can see myself.

That error is related to failed login to Visual Studio community edition.
If you are not verified it will refuse to compile.

Are you sure?
Because it was compiling today. And broke when i’ve added new UStruct.

I’ve simplified code. I’ve removed all my template classes. Moved everything to .cpp and for some reason it works again.

That error can happen if you have a syntax error in one of the Macros so you probably wrote something wrong in the USTRUCT or UPROPERTY.