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"

C++ reference parameter is return value in Blueprint

Hello,

I have a small problem where I have a static function in a class inherited from UBlueprintFunctionLibrary which should enable Blueprint graphs to set a variable in a structure. The function declaration looks as following: UFUNCTION(BlueprintCallable, Category = Loadout) static void SetLoadoutSlot(FLoadoutStruct & Data, uint8 SlotIndex, const FLoadoutSlotStruct & Slot);

Now the problem is that because the Loadout paramter is passed by reference, the engine thinks that it is supposed to be an out parameter so the blueprint node looks like this: alt text

Is there a way to tell the engine not to use the parameter as an output value or do I have to return a new structure instance with this function every time I modify a value in it?

Product Version: UE 4.8
Tags:
screenshot.png (14.5 kB)
more ▼

asked Jul 31 '15 at 09:00 PM in C++ Programming

avatar image

Fluppi393
457 36 33 54

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

2 answers: sort voted first

I knew I'd read some way of doing this but it took me ages to finally find it again. This should really be properly documented. Anyway, here you go.

 UFUNCTION(BlueprintCallable, Category = Loadout)
 static void SetLoadoutSlot(UPARAM(ref) FLoadoutStruct& Data, uint8 SlotIndex, const FLoadoutSlotStruct& Slot);

more ▼

answered Aug 01 '15 at 08:59 AM

avatar image

kamrann
2.1k 83 37 121

avatar image Fluppi393 Aug 01 '15 at 09:05 AM

Thanks a lot kamrann! Exactly what I was looking for! I think they should add this to the UFunction documentation page so it is easyer for people to find it.

avatar image Kory Aug 06 '15 at 02:22 PM

Yep, same here, it would have taken me quite a while to figure this one out, thanks for digging it up for us.

avatar image jstzwd Oct 27 '15 at 05:54 AM

Thanks man, really helps!

avatar image Muit Jan 16 '17 at 12:31 PM

I love you <3

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

Hi,

looks weird that first input param shows in blueprint as output, try add another one before it like

UFUNCTION(BlueprintCallable, Category = Loadout) static void SetLoadoutSlot(uint8 EmptyParamTest, FLoadoutStruct & Data, uint8 SlotIndex, const FLoadoutSlotStruct & Slot);

will EmptyParamTest become output pin then?

p.s. don't forget mark question as answered with little gray circle button under any answer (not comment, but whole answer) when problem solved, so anyone else later can have same question and may find solution faster, if you find solution on your own, don't forget write it too

more ▼

answered Aug 01 '15 at 01:57 AM

avatar image

happyhorror
576 54 46 72

avatar image Fluppi393 Aug 01 '15 at 08:43 AM

Hello, my problem here is that a parameter passed by reference will be exposed as an output value in blueprint. For functions like void GetTransforms(FVector & OutLocation, FRotator & OutRotation) this makes sense, but in my case I want to modify a structure instance and therefore need a non const reference! It would be great if you had to specify which parameters are output values in the UFUNCTION macro or only use parameters as output which start with "Out".

Edit: And yes I tested it with an additional uint8 parameter as the first one, which will be a usual input in blueprint and the reference is still an output.

(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