Examine Blueprint's functions with Python/CPP?
Are there any possibilities to display all functions declared in one blueprint through the experimental python plugin? Furthermore getting the function calls from a specific function? I was experimenting with that and couldn't really figured it out. I managed to get a list of all Assets but what do I have to do next?
I guess somehow I need to build that blueprint class to access its declared functions !?
If it does not work with python is there any why to achieve that with a c++ plugin?
asked Jul 21 '18 at 11:46 PM in C++ Programming
I can tell you where that information is and how to do in C++
UE4 has reflection system which tracks infomation about code structure, each element is represented by UField object that is created when engine is initiated and your module is loaded (in case of blueprint when asset system is loaded, you cam't get it then load the blueprint asset) and each element type has own class, you probably already know one called UClass for clases as it most commonly used UField class.
Note that UFields is created both C++ and Blueprint classes and in case of C++ only thigns maked with macros (UPROPERTY, UFUNCTION etc) are visible in reflection system, otherwise those things cna be only used in C++ (most notably struct functions which reflection system don't support at all but you can still use them in C++)
UClass is easy to get (UStruct is also easy with StaticStruct()), to get UFunction to UProperty that is part of UClass you need to use TFieldIterator or FindField function
T will be UField class you searching so in your case UFunction, Owner is the class field is in (UClass inherence from UStruct so dont worry) and String name is a name of function (try adding spaces if it does not work)
here example of TFieldIterator:
This will loop across all functions ofcorse, all of them inherent and C++ and blueprint, or else you set 2nd argument of iterator to ExcludeSuper
If you choose to get all of them you can check, you can check if function if blueprint by checking if Native flag is not set and get and check owning class with GetOuterUClass() function to filter them out.
To call function from UFunction can use ProcessEvent function on object you want to call on
Params need to be any struct with types of arguments of function declared in exact same or order, void* will accept any pointer, but it gonna read the data as that struct with those types of arguments.
Now as for Python... i don't know :pi never codef in Python and i yet to touch it in UE4, one thing for sure if it using only exposed things same as blueprint then doing this is impossible in blueprints, but again i yet to even touch Python in UE4 so maybe some other person will have anwser for that
answered Jul 22 '18 at 01:34 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here