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"

Default Parameters with TArrays.

Here is my function declaration:

 virtual void SetCurrentScreen(TSubclassOf<UWavesUIScreen> newScreenParent, bool CloseAllOtherScreens, bool RemoveFromStack, const TArray<UWavesUIScreen*> ScreensToClose = TArray<UWavesUIScreen*>(), int32 id = 0);

Intelisense says it's fine but on compile I get: C++ Default parameter not parsed: ScreensToClose "TArray()"

I've tried using the parameter as a reference but with the same result. I've seen some code that passes a TArray of AActor* with a default parameter just fine.

Product Version: UE 4.8
Tags:
more ▼

asked Aug 28 '15 at 06:42 PM in C++ Programming

avatar image

SquidInABox
52 8 7 11

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

2 answers: sort voted first

You can use the AutoCreateRefTerm macro to do this. In the example below, MyOptionalParam will be given an empty array if non is provided via Blueprints.

 UFUNCTION(BlueprintCallable, meta = (AutoCreateRefTerm = "MyOptionalParam"))
 void MyFunction(TArray<AActor*> MyOptionalParam);

You can make multiple parameters have default values by putting multiple parameter names in the AutoCreateRefTerm string, separated by commas:

 UFUNCTION(BlueprintCallable, meta = (AutoCreateRefTerm = "MyOptionalParam1,MyOptionalParam2"))
 void MyOtherFunction(TArray<AActor*> MyOptionalParam1, TArray<AActor*> MyOptionalParam2);
more ▼

answered Jun 02 '16 at 04:47 PM

avatar image

bvisness
67 2 8 11

avatar image Sashka Sep 08 '16 at 10:24 AM

But it still require passing argument, if is called from code. (however in BPs it apparently works)

avatar image Kiruse Jan 28 '17 at 11:22 PM

Standard procedure Epic uses in the UE4 itself is to separate the C++ version from the Blueprint version by creating the function twice. Basically like so:

void Foo( FString MyString = FString() ); UFUNCTION(BlueprintCallable, meta = (DisplayName = "Foo", AutoCreateRefTerm = "MyString")) void K2Foo( FString MyString );

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

Do you use UFUNCTION here? Because this looks like UHT, not compiler error, it don't know how to translate this to reflection system which is more limited then of what C++ can do. You would need to remove UFUNCTION() to do this.

more ▼

answered Aug 28 '15 at 07:38 PM

avatar image

Shadowriver
36.7k 932 169 1111

(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