How to use structs properly?

So, I’ve an object I want to use as a data storage with ~10 variables and no functions, thus I made it struct.
I created an array and filled it with my custom structs and now I want to assign new value to some variables through custom function, blueprint available.
My function:



void UHexagonStruct::SetType(UObject* WorldContextObject, HexType newType, FHexagonData& data)
 {
	data.Type= newType;
 }


But my reference became OUTPUT in my Blueprint Editor. If I use “const FHexagonData&” instead of “FHexagonData&” everything is okay, it stays input, but of course in this particular case I can’t use “const”, I want to pass some data and modify it.
I can’t use pointers with structs, which make me sad panda
As far as I understand if I use this:



void UHexagonStruct::SetType(UObject* WorldContextObject, HexType newType, FHexagonData data)
 {
    	data.Type= newType;
  }


I just get a copy of struct and my copy get new type and after this I should assign this copy to corresponding member of array, but I don’t want to iterate through array twice each time I modify a little bit of something =_=
So, am I doing something wrong, should I change structs to classes?
//Sorry for a messy text

Dear zeOrb,

That is indeed a characteristic of how Blueprint nodes get created from function headers.

If you pass by non-const reference, it becomes an output, not an input

This is actually a big deal and hopefully Epic can address your use case to see what best solution is

I know that blueprint-friendly structs and break-struct is coming to UE4 soon so you probably just need to wait till that is ready!

So rest assured this issue will be a non-issue soon :slight_smile:

Rama

Thanks for answer, Rama!
Well, I found thread with similiar problem link-link](C++ and Blueprint Interaction Problems, Pointers? - C++ - Epic Developer Community Forums)
I have a feeling I should switch structs array to classes array, while it’s not too late

Ah, you can tell Unreal that a ‘pass by reference’ is actually an input like this:


UFUNCTION(BlueprintCallable, Category="Math|Random")
static void SeedRandomStream(UPARAM(ref) FRandomStream& Stream);

0_0 It’s changes everything, huuuuge thanks!

1st sorry for necro
2nd this stuff should be in docs, just found macro header file and there is so much there that is makes nice reading list! XD nice tip! thank you.