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"

Custom class constructor?

Is it possible to have my own constructor in a class derived from UObject?

If yes, how should I pass the parameters to the constructor while instancing it with NewObject() since new seems not to be supported anymore?

Product Version: UE 4.8 Preview
Tags:
more ▼

asked May 25 '15 at 03:31 AM in C++ Programming

avatar image

SyMutex
205 11 9 23

(comments are locked)
10|2000 characters needed characters left

3 answers: sort voted first

As far as I know this is not possible. The suggested workaround is to define your own Init function which you can call after instantiating the object.

more ▼

answered May 25 '15 at 07:19 AM

avatar image

staticvoidlol
2.6k 95 40 111

avatar image SyMutex May 25 '15 at 01:56 PM

In this case, is it even reasonable to derive every custom class from UObject? Should I rather use raw c++ classes when there is no need to interact with the UE4 engine?

avatar image staticvoidlol May 25 '15 at 02:15 PM

Well, there's nothing wrong with that - it just depends on whether or not you want to use any of the good stuff like reflection and garbage collection built into the Unreal framework.

(comments are locked)
10|2000 characters needed characters left

As far as I know this is not possible. The suggested workaround is to define your own Init function which you can call after instantiating the object.

more ▼

answered May 25 '15 at 07:19 AM

avatar image

staticvoidlol
2.6k 95 40 111

avatar image staticvoidlol May 25 '15 at 01:43 PM

I think my good twin is posting answers as well.

(comments are locked)
10|2000 characters needed characters left

hi~ SyMutex.

i think, i can give you a clue.
replace 'GENERATED_BODY()' to ''GENERATED_UCLASS_BODY()' in header file of your custom class.

good luck ;)

more ▼

answered May 29 '17 at 06:26 AM

avatar image

MikiTheBabyDog
8 1 4 7

(comments are locked)
10|2000 characters needed characters left
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