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"

How to properly insert Engine-Default Enums in FStructs

I'm trying to make an FStruct to facilitate Function Input communication for Tracing. I'm using the instructions from this page:

https://docs.unrealengine.com/en-us/Programming/Development/CodingStandard

Here's the .h

 USTRUCT(BlueprintType) struct FMakeTraceInfo //Declaration. This Struct is used to Reduce FunctionInput Node sizes.
 {
     GENERATED_BODY()
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HitInformation")
     ETraceTypeQuery TraceType;
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HitInformation")
     bool TraceComplex;
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HitInformation")
     EDrawDebugTrace DrawType;
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HitInformation")
     TArray<AActor*> IgnoreArray;
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HitInformation")
     bool IgnoreSelf;
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HitInformation")
     FLinearColor TraceColor;
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HitInformation")
     float DrawTime;
 

However, compiling this produces the following error: "You cannot Use Raw Enum Name as a Type. Instead, use TEnumAsByte or a C++11 Enum Class with Explicit Underlying Type."

If I use

 TEnumAsByte <ETraceTypeQuery>  

is says illegal use (with reason), and if I use

 TEnumAsByte<ETraceTypeQuery::Type>

it says that it TEnumAsByte cannot convert to ETraceTypeQuery. I'm guessing that the proper way is by including it as a C++11 type. How would I include it this way?

Product Version: UE 4.20
Tags:
more ▼

asked Oct 27 '18 at 07:46 PM in C++ Programming

avatar image

me4dinosaur
279 15 18 21

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

2 answers: sort voted first

When compiling this struct in my 4.20 project the exact combination that worked was this:

 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HitInformation")
 TEnumAsByte<ETraceTypeQuery> TraceType;
 
 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HitInformation")
 TEnumAsByte<EDrawDebugTrace::Type> DrawType;

Both those enumerations needed to be declared as TEnumAsByte but EDrawDebugTrace is declared differently. Make sure you are including Kismet/KismetSystemLibrary.h.

more ▼

answered Oct 30 '18 at 07:05 PM

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

For anyone that ever stumbles upon this question, the answer is in the following:

Look up at the Enumerator's declaration (visit there respective Class' page on Epic's documentation). If it's an Enumerator declared below c++ 11, it will have a "namespace" tag on it. That declaration is the following

 TEnumAsBtye<Enum::Type>

If it is an Enum 11, it will have an UEnum declaration on it. That one is simply

 TEnumAsByte<Enum>
more ▼

answered Apr 08 '19 at 06:07 PM

avatar image

me4dinosaur
279 15 18 21

(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