Getting blueprint class from C++ plugin

I’m trying to extend the blueprint editor by adding a plugin that grabs data from the blueprint editor that is currently open (blueprint data, editor data, etc.). However, I can’t seem to find a way to get access to the blueprint I am currently editing without changing the source code which I am trying to avoid. Does anyone know a workaround to get access to the blueprint object/editor that a tab is attached to?

Thanks.

You can use a constructor helper called FClassFinder

How to use:
Include the ConstructorHelpers.h

#include "Runtime/CoreUObject/Public/UObject/ConstructorHelpers.h"

Go to your plugin’s constructor (constructor helpers only work on constructors) and use FClassFinder like so:

ConstructorHelpers::FClassFinder<BPClassTypeYouNeedToFind> NameOfResult(TEXT("/Game/PathOfYourBPClass"));

Now you can get what you want from your result, so if you need its class, then do:

if(!ensure(NameOfResult.Class)) { return; }

TheClassIWant = NameOfResult.Class;
1 Like

Thanks for the answer!
Is there a way for me to get the path of the blueprint without manually putting it in? I am trying to grab an instance of a given blueprint in a tool, not just a specific one.

Well, constructor helpers need hardcoded paths and I really don’t think there is a C++ function that doesn’t. I use blueprints for defaults just to avoid hardcoded paths. The only workaround I can think of is if you somehow generate the path of the instance and send it over as a variable to the helper before your plugin’s contruction.

Do you already have a pointer to the object and want to get it’s Blueprint asset or you want to access an object pointer from editor?