x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?

Product Version: UE 4.18
Tags:
more ▼

asked Jan 23 '18 at 11:31 PM in C++ Programming

avatar image

ChaserTheDragon
39 4 5 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Jan 23 '18 at 11:52 PM

avatar image

Jin_VE
4.4k 32 79 42

avatar image ChaserTheDragon Jan 24 '18 at 12:08 AM

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!

avatar image Jin_VE Jan 24 '18 at 12:40 AM

And compiling is half the battle... GI Joeeeeee! :)

Good luck.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question