Unable to expose an engine c++ function to blueprints

Hello!

I’m trying to expose a C++ function in the engine source code so I can use it within a blueprint actor. Specifically, it’s a function that is contained within the HierarchicalInstancedStaticMeshComponent.h header file (located in Engine > Source > Runtime > Engine > Classes > Components). The function is called “BuildTreeIfOutdated” and I’ve added a line of code above it so it now reads:

	UFUNCTION(BlueprintCallable, Category = "Components|InstancedStaticMesh")
	bool BuildTreeIfOutdated(bool Async, bool ForceUpdate);

I then saved, opened up my project and compiled, but the function doesn’t appear in a blueprint derived from that class. I’ve even tried deleting saved, intermediate, and binaries, generating studio project files, and rebuilding, but to no avail; the function still doesn’t seem to be blueprint callable.

I’m very new to C++ (at least in UE4) but I’m struggling. I’m sure there is something simple I’m missing. Would appreciate some pointers or places to look for more information.

Thanks for your help!

There was a much simpler way to go about this… I just created a C++ subclass of the HierarchicalInstancedStaticMesh and added a blueprint callable function with a call to the BuildTreeIfOutdated function inside of it.

When you say you made a subclass, do you mean you made a derived class? I cannot for the life of me figure out how to actually do what you are describing, and all the solutions I see online are people who have done this and don’t ever post how they did it. Can you please show where you reference the function at in your subclass, and how to actually access it in a blueprint? What all do you have to write in the subclass header/cpp file to do this? Do you just expose the function?

I am trying to do something very similar with PaperGroupedSprite, where I expose the AddInstanceWithMaterial function to blueprints, but I can’t get the syntax right or I’m just missing something. I feel it should be very simple, but I am noob at cpp.

Here’s my cpp and header files. Hope it helps:

FoliageISMWithBenefitsComponent.cpp

#include "FoliageISMWithBenefitsComponent.h"

FoliageISMWithBenefitsComponent.h

#pragma once

#include "CoreMinimal.h"
#include "FoliageInstancedStaticMeshComponent.h"
#include "FoliageISMWithBenefitsComponent.generated.h"

/**
 * 
 */
UCLASS(Blueprintable)
class MYGAME_API UFoliageISMWithBenefitsComponent : public UFoliageInstancedStaticMeshComponent
{
	GENERATED_BODY()
	
public:
	UFUNCTION(BlueprintCallable, Category = "Components|InstancedStaticMesh")
	void RefreshCustomDataFoliage() {
		BuildTreeIfOutdated(true, false);
	}
};

Basically I just encapsulated the BuildTreeIfOutdated function into another function (RefreshCustomDataFoliage) and then made that new function blueprint callable so now I can use it in my new blueprint class. The new blueprint class I created is a child of this FoliageISMWithBenefitsComponent class.

Ahh I see that’s smart, I ended up doing something a little less efficient for mine - I just remade the function I wanted to expose in my child’s .cpp file and renamed it haha. Thanks for the openness and help, your solution seems to be the best play