Unresolved external symbol - accessing Editor Mode static method

Hi,

I’m trying to write an editor plugin that can resimulate all the ProceduralFoliageVolumes in the world context. To do this I’m using the following code, patterned after the implementation of FProceduralFoliageComponentDetails::OnResimulateClicked() in Editor/FoliageEdit/Private/ProceduralFoliageComponentDetails.h:

for (TActorIterator<AProceduralFoliageVolume> FoliageVolumeItr(World); FoliageVolumeItr; ++FoliageVolumeItr)
{
	bool bGenerageSucceeded = false;
	
	if (FoliageVolumeItr->ProceduralComponent->FoliageSpawner == nullptr)
	{
		UE_LOG(LogTemp, Warning, TEXT("Unable to resimulate %s: FoliageSpawner is nullptr"), *FoliageVolumeItr->GetName());
		continue;
	}

	bGenerateSucceeded = FoliageVolumeItr->ProceduralComponent->GenerateProceduralContent(OutFoliageInstances);
	if (bGenerateSucceeded)
	{
		UE_LOG(LogTemp, Warning, TEXT("GenerateProceduralContent succeeded for %s"), *FoliageVolumeItr->GetName());
		FEdModeFoliage::AddInstances(World, OutFoliageInstances);
	}
}

However, I keep getting the following error: error LNK2019: unresolved external symbol “public: static void __cdecl FEdModeFoliage::AddInstances(class UWorld *,class TArray const &)” (?AddInstances@FEdModeFoliage@@SAXPEAVUWorld@@AEBV?$TArray@UFDesiredFoliageInstance@@VFDefaultAllocator@@@@@Z) referenced in function “public: void __cdecl USpawnTool::ResimulateAll(void)” (?ResimulateAll@USpawnTool@@QEAAXXZ)

As far as I can tell, AddInstances isn’t accessible for some reason, maybe because its header file (Editor/FoliageEdit/Private/FoliageEdMode.h) isn’t part of the normal API. Is there a way I can make it accessible? I’d really like to use this function, and I’m not sure I can resimulate any volumes without it.

Here’s a list of my includes if they’d be helpful:
“Engine.h”, “Editor.h”, “SlateBasics.h”

“ProceduralFoliageSpawner.h”, “ProceduralFoliageVolume.h”, “ProceduralFoliageComponent.h”, “FoliageType.h”, “InstancedFoliage.h”

“Editor/UnrealEd/Public/EditorModes.h”, “Editor/UnrealEd/Public/EditorComponents.h”, “Editor/UnrealEd/Public/EdMode.h”, “Editor/FoliageEdit/Private/FoliageEdMode.h”, “Editor/PropertyEditor/Public/IDetailCustomization.h”, “Editor/FoliageEdit/Private/ProceduralFoliageComponentDetails.h”

“Editor/UnrealEd/Classes/Builders/EditorBrushBuilder.h”, “Editor/UnrealEd/Classes/Builders/CubeBuilder.h”

Try adding PrivateDependencyModuleNames.AddRange(new string[] { "FoliageEdit" }); to YourPrjectName.Build.cs file and save it. Then right click on your uproject file and select Generate Visual Studio project files.

I just tried it, but it still gives me the same error. I had also put “FoliageEdit” into the Private and Public Dependencies in my plugin’s Build.cs file earlier, but that didn’t fix it either.

I figured it out. The class I was trying to access was not flagged for export, so I couldn’t access from another class it through the API. I had to replace line 193 of FoliageEdMode.h with “class FOLIAGEEDIT_API FEdModeFoliage : public FEdMode” instead of “class FEdModeFoliage : public FEdMode”. After that, I just recompiled the engine from source and it worked.

Hi! I’m glad someone wanted the same and succeeded. But recompiling the engine is beyond my knowledge. I’m trying to get the same “Resimulate All” or at least “Resimulate Selected” function from blueprints. If you could possibly look into my form thread, I would really appreciate it. Maybe you would have some advice or idea. How to press the "Resimulate" button from the editor utility blueprint on procedural foliage actor? - Blueprint Visual Scripting - Unreal Engine Forums