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 expose GetDayOfWeek() to blueprints?

I have exposed functions to blueprints before but I definitely somewhat of a novice C++ programmer. GetDayOfWeek returns data type EDayOfWeek. I just get the below when I try to return that type

From the compiler(xcode):

Unrecognized type 'EDayOfWeek' - type must be a UCLASS, USTRUCT or UENUM

Then if try to return it as an uint8 or something else I get errors saying that I can't use that type. Can anyone else expose this to blueprint?

https://forums.unrealengine.com/development-discussion/c-gameplay-programming/64217-exposing-datetime-s-getdayofweek-to-blueprints-how-can-i-return-an-edayofweek

Here is the code I'm trying at the moment and isn't working.

.cpp

 EDayOfWeek UDateTimeFunctions::GetDayOfWeek(FDateTime dTime)
 {
 return dTime->GetDayOfWeek();
 }

.hp

 UFUNCTION( BlueprintPure, meta = (DisplayName = "Get Weekday", Keywords = "Calendar, Day, Weekday, Date, Time"), Category = Custom )
 static EDayOfWeek GetDayOfWeek( FDateTime dTime );

Here is a previous link to a forum where the issue was discussed but there was no concrete resolution, or at least, i wasn't sure on how the problem is solved.

Many Thanks

Product Version: UE 4.21
Tags:
more ▼

asked Jan 08 '19 at 03:00 PM in C++ Programming

avatar image

jakenicolaides
34 3 4 10

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

2 answers: sort voted first

You were correct =P, just do this then.

alt text

0.png (30.3 kB)
more ▼

answered Jan 08 '19 at 10:05 PM

avatar image

Evigmae
1.7k 8 4 8

avatar image jakenicolaides Jan 08 '19 at 10:11 PM

That works. Thank you! It really helps when learning C++ when you have people to show you the way now and again. Thanks again.

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

how about something like this?

.h

alt text

.cpp (add: #include "Misc/DateTime.h")

alt text

header.png (3.7 kB)
implementation.png (22.0 kB)
more ▼

answered Jan 08 '19 at 03:42 PM

avatar image

Evigmae
1.7k 8 4 8

avatar image jakenicolaides Jan 08 '19 at 04:15 PM

Ah brilliant. I will try that out when I get home. Looks like it doesn't use that EDayOfWeek Enum thus avoiding the problem, which I hadn't considered doing. Thanks so much for your help. Will mark as answer as soon as I test it out.

avatar image jakenicolaides Jan 08 '19 at 09:38 PM

Getting this unfortunately...am I doing something super dumb?

alt text

avatar image Evigmae Jan 08 '19 at 09:40 PM

yeah, GetDayOfWeek() returns EDayOfWeek, GetDay() returns an int32 :)

Also, #include "Misc/DateTime.h"

avatar image jakenicolaides Jan 08 '19 at 09:43 PM

ah of course! Thanks so much for your help :)

avatar image jakenicolaides Jan 08 '19 at 09:47 PM

Doesn't GetDay return the current day of the month though, not the day of the week?

avatar image Evigmae Jan 08 '19 at 09:50 PM

Internally it gets year/month/day, and returns day.

I get your point. let me check.

edit: btw, today it thinks is tuesday, which is right. so i guess it's value is like day%7 or something. if it was returning an 8 it would print nope.

avatar image jakenicolaides Jan 08 '19 at 09:52 PM

well that will give me an int between 1 to 31 right(depending on the month)? not 0 to 6

(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