Hi everyone
I have this problem that confuses me: my functions in the blueprint function library cannot change the values passed in those function.
I have a blueprint function library class named “FileManager”, in this class i have a Test funciton which has 2 input: a FString, a Interger.And i try to change the two values in the function like this,
Where’s the function called inside your blueprint? Anyway the FString and int should be a reference (FString& and int&), because otherwise you’re changing only a copy of them (at least in C++, I don’t know if blueprints do the same or they have something inside the reflection system to avoid this).
Hi mate,I have just tried the (FString & , int & ) as input parameters .
I know the difference between FString Str and FString& Str (when they are params for a function), your advice will absolutely work in normal c++ code.
But when i tried it in the blue print function library function, it compiled well ,but in the bp this function would’t have any inputs, and all the params which should be inputs became outputs! That’s weird.
My c++ code is:
Yeah, that should work, I didn’t remembered that references are considered output parameters by default for BPs, but maybe the UPARAM(ref) method is more efficient. Check this wiki article: wiki.unrealengine.com
Yes.
I have got suggestion that: in most c++ cases(including Unreal), if a function is taking refs as input params, it will automatically take them as to-be-changed params, so the original values won’t matter(in most case).
It looks the same in the normal c++, when you call the function you still have to give the refs as inputs. But in the Unreal BPs , it won’t let you give input to the function ,but only gives output which the funtion would change in itself.
So using UPARAM(ref) in the function’s declaration should work on my case…