You forgot to change your 9th line in CustomAsset.h. You have:
class TESTPROJECT_API URobotCreationData : public UDataAsset
however your asset’s class is called UCustomAsset everywhere else in the code you provided. So it should be:
class TESTPROJECT_API UCustomAsset : public UDataAsset
(remember to change it in 13th line too)
Also, 5th line of your CustomAssetFactory.cpp should be:
#include "CustomAssetFactory.generated.h"
(without “U” at the begining)
And this is how your 3rd line in CustomAssetFactory.cpp should look like:
#include "CustomAssetFactory.h"
Again, no “U” at the begining.
File name shouldn’t include class prefix as well afaik (unless it’s a slate widget class, but it’s not the case).
So instead of having UCustomAssetFactory.h and UCustomAssetFactory.cpp you should have CustomAssetFactory.h and CustomAssetFactory.cpp. The same goes for your UCustomAsset.h and UCustomAsset.cpp.
I was playing with custom assets recently too, and from what I see here, I think there might be more problems after solving this one but i’m not sure yet. So let’s firstly fix compilation errors.
hi,
I am trying to create a custom content browser asset using UDataAsset and UFactory. Here is my code:
UCustomAsset.h:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "Runtime/Engine/Classes/Engine/DataAsset.h"
#include "CustomAsset.generated.h"
UCLASS()
class TESTPROJECT_API URobotCreationData : public UDataAsset
{
GENERATED_BODY()
public:
UCustomAsset::UCustomAsset(const FObjectInitializer& ObjectInitializer);
//~CustomAsset();*/
UPROPERTY(VisibleAnywhere, BlueprintType, BlueprintReadWrite)
int32 TestProperty;
};
UCustomAsset.cpp:
// Fill out your copyright notice in the Description page of Project Settings.
#include "TestProject.h"
#include "UCustomAsset.h"
UCustomAsset::UCustomAsset(const FObjectInitializer& ObjectInitializer)
:Super(ObjectInitializer)
{
}
UCustomAssetFactory.h:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "UnrealEd.h"
#include "UCustomAssetFactory.generated.h"
UCLASS()
class TESTPROJECT_API UCustomAssetFactory. : public UFactory
{
GENERATED_BODY()
UCustomAssetFactory.(const FObjectInitializer& ObjectInitializer);
virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override;
};
Hi,
Originally the asset was called “URobotCreationData”, but when I posted here, I decided to rename asset to UCustomAsset for simple. I forgot to do it in a few places. You found them. So, it isn’t the source of problem.
But I didn’t know that files must not start with “U”.
But still, thanks for your response.