Pass Content Window Actors/BlueprintFunctionLibrary to C++ Function.
i would like to know how I can pass the actors or my BlueprintFunctionLibrary in my content window to c++ functions. Is there a way to do that?
Basically pass this:
It would also be ok if I could just use a UPROPERTY:
But I cannot select this library, why does it not show up in this list?
What can I do to access this function library?
asked Oct 29 '18 at 04:33 PM in C++ Programming
I think you misunderstanding the role of BlueprintFunctionLibrary. Technically you can do blueprints nodes on in any UObject and AActor based class (so practically anywhere), BlueprintFunctionLibrary only exists for static functions for nodes that you can not logically relate to any of the classes you have or you want to or you want to make node out of something that can not be direly exposed to blueprint (like non-UObject class or C++ struct functions).
For example all math functions in C++ inside UE4 are packed to FMath structure, blueprint don't support functions in structures and also math operators from C++ (aspecially for premitive types) can not be bind to blueprint, there for UBlueprintFunctionLibrary class was made called UKismetMathLibrary (Kismet is node scripting system in UE3 and blueprint suppose to be Kismet 2.0 thats why you can still see that name in UE4) which contains static function with all math operations which are bind to blueprints, and only reason why they are there is due to limitations of blueprints.
What im getting at? Those libraries suppose to only contain static functions and object for then should not be never created, if you corner yourself to need to pass blueprint library as object that means you doing something wrong. if you want to create node for object it should be in class of that object, if you need global variable for any node operations you place those in either GameMode or GameInstance or PlayerController. So you probably need to reconsider what you doing, you didn't explained why you doing this so i can't really suggest you anything here.
Now the reason why you don't see those object is something compliantly different. You can see object in property editor only in those cases:
1.Object you trying set property in exists on the level (this includes World Settings and Level Blueprint) and object you trying to set property in exists in exact same level
2.Object is registered asset on content editor (like UTexture, UStaticMesh etc)
Reason why you can do that only in those cases is because you making a class not a object and when object of a class is created there no guaranty that selected object will exists on creation of that object, or else those consitions are met. If you have object already created on the level editor there guaranty that other objects saved on the level will also exist, thats hwy you can select them, if you spawn object of class in any other moment there no guarranty that those object exist anymore... there no guarranty you spawn on same level you editing, how UE4 suppose to know that? thats why you can not to do that on raw blueprint class. While assets in content browser exists in asset registry and will be packaged in the game so UE4 can also ensure of existence of those objects in any moment.
You can only select class (UClass* or TSubclassOf) anywhere and then create object of it in the blueprint.
If oyu don't understand, think blueprint as C++ class (because thats essentially what it is) and in C++ you can not just grab C++ class and call function on it or else functions are static, you need a object to be made of that class, blueprint is exactly bound to same limitation. "Class" as name suggest just defines class/type of objects not the object instance.
answered Oct 29 '18 at 09:45 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here