I have added struct to project using add code to project. Everything compiles, but once I load editor it crashes.
From the debug it looks like this call from generated file crashes.
I see that you are using the standard c++ ctor. An USTRUCT is a bit different and the constructor must go within a #if CPP block. Try this one (no .cpp file in my case, all in the header):
//
// UnitStuct.h
//
#pragma once
#include "UnitStuct.generated.h"
/**
* Unit struct with default construictor to initialize values
*/
USTRUCT()
struct Funit_struct
{
GENERATED_USTRUCT_BODY()
UPROPERTY()
int8 intUnitStrenght;
#if CPP
Funit_struct() :
intUnitStrenght(0)
{
// Default constructor
}
#endif
};
Thanks for the reply, adding if cpp made it failed as well. But I noticed you didnt used USTRUCT() before declaring struct, which I had. So I removed it and it didnt crash.
I wanted to make it visible in bluprints that why I used USTRUCT(BlueprintType).
Another funny thing. Removing USTRUCT made it work. But if I rebuild solution it says no generated h file found.
I need to add back USTRUCT, rebuild, remove USTRUCT() and then it works after build (not rebuild). Preatty much weird behavior.