How do I extend UGlobalEditorUtilityBase? (Blutility)

Hello,
I’m looking to create a Blutility. I know I can create a Blueprint for this in the Editor but I need to expose more functionality to the Blueprint from C++ before I do this. What I figured I’d do is extend UGlobalEditorUtilityBase and then create a Blueprint from that.

However when I try to extend this like I would a UObject or AActor I get the following error:

Error	1	error : Failed to generate code for GrottoCustodianEditor	D:\UE4\Projects\GrottoCustodian\Intermediate\ProjectFiles\EXEC	GrottoCustodian

Error	2	error : UnrealHeaderTool failed for target 'GrottoCustodianEditor' (platform: Win64, module info: D:\UE4\Projects\GrottoCustodian\Intermediate\Build\Win64\GrottoCustodianEditor\Development\UnrealHeaderTool.manifest).	D:\UE4\Projects\GrottoCustodian\Intermediate\ProjectFiles\EXEC	GrottoCustodian

Error	3	error MSB3073: The command "D:\UE4\Git\UnrealEngine\Engine\Build\BatchFiles\Build.bat GrottoCustodianEditor Win64 Development "D:\UE4\Projects\GrottoCustodian\GrottoCustodian.uproject"" exited with code -1.	C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets	38	5	GrottoCustodian

I’ve been trying a whole range of things but currently my source files looks like this:

// MyBlutilityBase.h
#pragma once

#include "Editor/Blutility/Classes/GlobalEditorUtilityBase.h"
#include "MyBlutilityBase.generated.h"


UCLASS(Blueprintable)
class UMyBlutilityBase : public UGlobalEditorUtilityBase
{
public:
	GENERATED_UCLASS_BODY()
	void MyFunction();
};

// MyBlutilityBase.cpp
#include "GrottoCustodian.h"
#include "MyBlutilityBase.h"


UMyBlutilityBase::UMyBlutilityBase(const FPostConstructInitializeProperties &PCIP)
: Super(PCIP)
{

}

void UMyBlutilityBase::MyFunction()
{

}

Any help at all would be appreciated.

With your additions this built fine, thanks a lot for the quick answer.

Is there a reason this class is not exposed to be extended, other then Blutilities still being experimental?

From a purely code-based standpoint, you would need to include Blutility as a module dependency in your .Build.cs file, it seems that you’ll also need to include UnrealEd.h to get that building too (and add that as a dependency too).

In your header:

#include "UnrealEd.h"
#include "GlobalEditorUtilityBase.h"

In your .Build.cs file:

PrivateDependencyModuleNames.AddRange(new string[] { "UnrealEd", "Blutility" }); // or PublicDependencyModuleNames

But even then it won’t link, since UGlobalEditorUtilityBase isn’t exported (if it was, it should have BLUTILITY_API before its class name):

class BLUTILITY_API UGlobalEditorUtilityBase : public UObject

I can’t find anything in code that derives from that type, it seems that all derivation might happen via blueprint generated classes, so I’m not sure this is something you’re supposed to be able to do in C++.

I’m unsure, but I’ve asked around internally, so hopefully someone will be able to provide you with an answer to that question. Hopefully it’s just an oversight on our part.

Good news!

I’ve checked and this is indeed an oversight on our part. I’ll be submitting a fix for this tomorrow, but it won’t make it out in a release until 4.2.

You’re fine to keep that fix you’ve made locally until then.

Excellent!
I don’t know if the PlacedEditorUtilityBase is supposed to be usable at the moment but you may want to give that a once over while you’re at it. Either way thanks :slight_smile:

Thanks, both these have been updated and are now in master (they will be in the 4.2 release).

https://github.com/EpicGames/UnrealEngine/commit/5e424f9034a9c8dc54a9c6016eb03898979d960d