Identifier "ContructObject" is not defined

ConversationFactory.h:

#pragma once
#include "UnrealEd.h"
#include "CoreUObject.h"
#include "Conversation.h"
#include "ConversationFactory.generated.h"

UCLASS()
class UConversationFactory : public UFactory
{
	GENERATED_UCLASS_BODY()

	// UFactory interface
	virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override;
	// End of UFactory interface
};

and ConversationFactory.cpp

#include "ConversationFactory.h"

#define LOCTEXT_NAMESPACE "Conversation"

/////////////////////////////////////////////////////
// UConversationFactory

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

UObject* UConversationFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn)
{
	UConversation* NewObjectAsset = ConstructObject(Class, InParent, Name, Flags | RF_Transactional);
	return NewObjectAsset;
}

#undef LOCTEXT_NAMESPACE

And when I try to compile this, VS says that the identifier “ContructObject” is not defined. What am i doing wrong?

Weird… I can’t find ConstructObject anywhere in the engine source other than in comments. It looks like the function was pulled out but I don’t see any deprecation announcement online. Under one comment that mentions ConstructObject, there is a call to NewObject so it looks like you should work with that one instead.

Yes, I changed

UConversation* NewObjectAsset = ConstructObject(Class, InParent, Name, Flags | RF_Transactional);

to

UConversation* NewObjectAsset = NewObject<UConversation>(InParent, Class, Name, Flags | RF_Transactional);

and now it compiles perfectly!

And compiling is half the battle… GI Joeeeeee! :slight_smile:

Good luck.