Creating custom content browser asset don't work

anonymous_user_95ee26c9
Tue, 09 Aug 2016 12:10:51 +0000
C++

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;
};

UCustomAssetFactory.cpp:

#include "TestProject.h"
#include "UCustomAsset.h"
#include "UCustomAssetFactory.h"

UCustomAssetFactory::UCustomAssetFactory(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
{
	bCreateNew = true;
	bEditAfterNew = true;
	SupportedClass = UCustomAsset::StaticClass();
}

UObject* UCustomAssetFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn)
{
	UCustomAsset* NewObjectAsset = NewObject<UCustomAsset>(Class, Name);
	return NewObjectAsset;
}

This doesn’t compile. It doesn’t like UCustomAsset Declaration, therefore it finds an error in every line that uses it.

VS shows an error is at the line with the UCLASS() in UCustomAsset.h
Error message is: this declaration has no storage class or type specifier

Also, I provide the link for the tutorial on which this code is based:

Wraiyth's Blog – 11 Mar 15

Creating a Content Browser Asset in UE4

Sometimes when working in UE4, you might want to create instances of your object in the Content Browser as assets that can be saved out to disk, or have custom editors associated with them. For ins…

3 posts - 1 participant