Download

native USTRUCT not creating break/make for BP

Hi there,

i have my native USTRUCT build like this


USTRUCT()
struct FInventoryItemData
{
	GENERATED_USTRUCT_BODY()

	//Always make USTRUCT variables into UPROPERTY()
	//    any non-UPROPERTY() struct vars are not replicated

	// So to simplify your life for later debugging, always use UPROPERTY()
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Item)
		FItemData		ItemData;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Item)
		UUserWidget*	ItemWidget;


	//Set
	void SetItemData(FItemData NewValue)
	{
		ItemData = NewValue;
	}
	void SetItemWidget(UUserWidget* NewValue)
	{
		ItemWidget = NewValue;
	}

	//Get
	FItemData		GetItemData()
	{
		return ItemData;
	}
	UUserWidget*	GetItemWidget()
	{
		return ItemWidget;
	}
	

	//Constructor
	FInventoryItemData()
	{
		//Always initialize your USTRUCT variables!
		//   exception is if you know the variable type has its own default constructor
		FInventoryItemData*		ItemData = NULL;
		UUserWidget*			ItemWidget = NULL;
	}
};  //Always remember this ;  at the end! You will get odd compile errors otherwise


it should add make/break functions in blueprinting but it does not.
Can you tell me whats going on?

EDIT: to make it work after 4.6 change USTRUCT() to USTRUCT(blueprintable).

FInventoryItemData is another UStruct both have their members as properties

thanks for any help!

Just to check, you’ve created a variable of this struct in your class right, and that’s what you’re trying to break? If not, that’s your first problem, you have to actually make a variable of the struct to be able to do anything with it. Structs are like floats/bools/any other variable type, they’re designed to be instanced/copied around and used all over :slight_smile:

Second, none of the functions inside the struct are marked with the UFUNCTION(BlueprintCallable) macro, which I’m fairly sure means they won’t be visible to blueprint at all. Never tried using functions inside structs, though it is possible.

Make a variable of the struct like so, and try to find and break that in blueprint. Should work!



UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category ="MyStructs"
FInventoryItemData InventoryVar;


hi, thank you for your help.

found the solution in answerhub.
I just needed to change USTRUCT() to USTRUCT(blueprintable).

I’m a bit surprised that blueprintable worked for you. The correct tag would be BlueprintType.

Blueprintable should only be for UCLASS and it designates that blueprints can be made with that as the ParentClass. I suppose it probably implies BlueprintType, so I guess that is why it worked, but you’ll be best off using BlueprintType as that one won’t risk changing out from you in the future.

Gets and Sets works on USTRUCTS? oO
Last time I’ve tried they were considered functions and thrown error (Maybe I’ve declared they wrong)…

As Mark suggested, you should be specifying BlueprintType in the USTRUCT(…) macro. As for the make/break problem, you can define your own make/break functions and specify them in a meta=(…) macro.

USTRUCT meta tags documentation](https://docs.unrealengine.com/latest/INT/API/Runtime/CoreUObject/UObject/UM___370/index.html)

UFUNCTION meta tags documentation](https://docs.unrealengine.com/latest/INT/API/Runtime/CoreUObject/UObject/UM___374/index.html)

The docs on these are lacking but you can check out the source for clear documentation on using them within ObjectBase.h.

USTRUCT meta tags:

HasNativeBreak
Indicates that the struct has a custom break node (and what the path to the BlueprintCallable UFunction is) that should be used instead of the default BreakStruct node.

HasNativeMake
Indicates that the struct has a custom make node (and what the path to the BlueprintCallable UFunction is) that should be used instead of the default MakeStruct node.

UFUNCTION meta tags:

NativeBreakFunc
For BlueprintCallable functions indicates that the function should be displayed the same as the implicit Break Struct nodes

NativeMakeFunc
For BlueprintCallable functions indicates that the function should be displayed the same as the implicit Make Struct nodes

Hope this helps :slight_smile: