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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Workaround for "FindObject" in Object Class

Hey guys, I want to get the name of an enum inside of a normal object class, but I get an error using FindObject in there. So my Question is: Is there any other way of getting the const UEnum* or another workaround for it?

alt text

Product Version: UE 4.18
screenshot-46.png (18.7 kB)
more ▼

asked Dec 25 '17 at 08:42 PM in C++ Programming

avatar image

52 5 9 16

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

2 answers: sort voted first

Ok, few notes:

  1. enum is not an object, so findobject wont work.

  2. if i understand correctly, in your constructor you want to set your variable "type"and "amount". Not assign your constructor variables to whichever the default values are for type and amount.

  3. when setting "type" correctly in your constructor, you can just use this same "type" variable as your class' enum.

more ▼

answered Dec 25 '17 at 10:14 PM

avatar image

219 4 3 4

avatar image MrZelektronz Dec 25 '17 at 10:22 PM

well, thanks for your comment, but it does not really help me :/ findobject will work (https://wiki.unrealengine.com/Enums_For_Both_C%2B%2B_and_BP) .I´m setting the variables correct, you could have been because they are named similarly.

avatar image IGorilla Dec 25 '17 at 10:35 PM

oh, i didnt know enums could be found like that.I stand corrected. your variables however should be set the other way around. item::type = type; and item::amount = amount;

that being said, what is the error it shows you?

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

Hi MrZelektronz,

First thing to note here is that in the code you posted, in the 2nd line of your function getName(), the variable type is undefined (unless you have defined it somewhere else which is not posted in your original question). That aside, in order to get the name of an enum as a FString you should do the followings:

  • Make sure that your enums are defined in a way that Unreal Engine can understand them. Here's two different way of defining Enums in an Unreal Engine friendly manner:

alt text

Note that they should be marked by the macro UENUM(/*Optional Specifiers*/). You can use any of these two versions and they will both work fine.

  • Having defined your enums properly, you can get the name of your enums as a FString and print them to Ouput log screen as such:

alt text

See that static_cast difference between the two version of Enums for this case? You do not need to include anything for this code to work as long as you have CoreMinimal.h included in your header file. However if the intellisense still fails to catch up and keeps giving you false warnings, you can #include "UObject/Package.h" in your .cpp file which should take care of these intellisense errors for you.

Hope this answered your question.

more ▼

answered Dec 25 '17 at 10:24 PM

avatar image

1.5k 10 10 17

(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