Hey lovely Unreal Community.
I’m relatively new with C++ coding inside of Unreal. The past few days I tried many things to solve the problem with my class, without any solution. I created the following .cpp and .h files over the classic workflow in Unreal.
.h File
#pragma once
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "ItemSettings.generated.h"
/**
*
*/
UCLASS(BlueprintType,Blueprintable)
class MYPROJECT_API UItemSettings : public UObject
{
GENERATED_BODY()
private:
FName id;
FText name;
bool allowed;
int32 mincount;
int32 maxcount;
//AActor actor;
public:
//UItemSettings();
UFUNCTION(BlueprintCallable, Category = "Item Settings")
FName getId();
UFUNCTION(BlueprintCallable)
FText getName();
UFUNCTION(BlueprintCallable)
bool isAllowed();
UFUNCTION(BlueprintCallable)
int32 getMinCount();
UFUNCTION(BlueprintCallable)
int32 getMaxCount();
/*
UFUNCTION(BlueprintPure)
AActor getActor();
*/
UFUNCTION(BlueprintCallable)
bool setAllowed(bool isAllowed);
UFUNCTION(BlueprintCallable)
int32 setMinCount(int32 count);
UFUNCTION(BlueprintCallable)
int32 setMaxCount(int32 count);
};
and the corresponding cpp file
#include "ItemSettings.h"
/*
UItemSettings::UItemSettings()
{
}
*/
FName UItemSettings::getId()
{
return UItemSettings::id;
}
FText UItemSettings::getName()
{
return UItemSettings::name;
}
bool UItemSettings::isAllowed()
{
return UItemSettings::allowed;
}
int32 UItemSettings::getMinCount()
{
return UItemSettings::mincount;
}
int32 UItemSettings::getMaxCount()
{
return UItemSettings::maxcount;
}
/*
AActor UItemSettings::getActor()
{
return UItemSettings::actor;
}
*/
bool UItemSettings::setAllowed(bool isAllowed)
{
return UItemSettings::allowed;
}
int UItemSettings::setMinCount(int32 count)
{
return UItemSettings::mincount;
}
int UItemSettings::setMaxCount(int32 count)
{
return UItemSettings::maxcount;
}
As far as good, but now I wonder why Unreal doesn’t show me my class inside the variables dropdown in a Blueprint. I use Live Coding with Visual Studio Community 2022 and I restarted the engine multiple times. As far as my knowledge goes I should have done everything right or?
Side nodes:
- I commented some things out, to check if there is just a problem with some variables or something like that.
- The class itself doesn’t appear inside the Unreal content browser under the C++/Public folder, maybe here lays the problem or is it because it is a UObject?
- Visual Studio and Unreal don’t show any problems with my code.
- I use Unreal Engine 5.3.2
Thank you in advance.