Download

C++ Source Method not Showing Up as Blueprint in Editor

I’m trying to add a module to the source code. Changes compile fine but the UFUNCTIONs I added don’t show up in Editor.

The goal is to keep my changes IN the source code. So to be clear, I’m building the engine from source. When I add my code as a new C++ class to a project it works just fine and shows up in the Editor as a Blueprint node. But if I add the module to the source code I get nothing.

Here is an example of what I’ve got:

In …/UE4/Source/Editor/MobileInteractionLibrary/MobileInteractionLibrary.Build.cs


using UnrealBuildTool;

namespace UnrealBuildTool.Rules
{ public class MobileInteractionLibrary : ModuleRules
{
  [INDENT=2]public MobileInteractionLibrary(ReadOnlyTargetRules Target) : base(Target)
{[/INDENT]
  [INDENT=3]PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore" });

PrivateDependencyModuleNames.AddRange(new string] { });

//The path for the header files
PublicIncludePaths.AddRange(new string] { "MobileInteractionLibrary/Public" });

//The path for the source files
PrivateIncludePaths.AddRange(new string] { "MobileInteractionLibrary/Private" });[/INDENT]
  [INDENT=2]}[/INDENT]
  } 
 }


In …/UE4/Source/Editor/MobileInteractionLibrary/Public/MobileInteractionLibrary.h


#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "MobileInteractionLibrary.generated.h"

UCLASS()
class MOBILEINTERACTIONLIBRARY_API UMobileInteractionLibrary : public UBlueprintFunctionLibrary
{ GENERATED_UCLASS_BODY()

UMobileInteractionLibrary();

public:
UFUNCTION(BlueprintCallable, Category = "Mobile Interaction|Sharing")
static void ShareURL(const FString& URL, const FText& Description, const FText& SharePrompt, int32 LocationHintX, int32 LocationHitY);
  
 };

In …/UE4/Source/Editor/MobileInteractionLibrary/Private/MobileInteractionLibrary.cpp


#include "MobileInteractionLibrary.h"
#include <string>

#if PLATFORM_ANDROID
#include "Android/AndroidPlatform.h"
#include "Android/AndroidApplication.h"
#include "../Source/Runtime/Launch/Public/Android/AndroidJNI.h"
#include "Android/AndroidJava.h"
#endif

UMobileInteractionLibrary::UMobileInteractionLibrary(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}

DECLARE_DELEGATE_FiveParams(FAndroidShareURLDelegate, const FString&, const FText&, const FText&, int32, int32);
CORE_API FAndroidShareURLDelegate OnAndroidShareUrl;

void UMobileInteractionLibrary::ShareURL(const FString& URL, const FText& Description, const FText& SharePrompt, int32 LocationHintX, int32 LocationHintY)
{
#if PLATFORM_ANDROID OnAndroidShareUrl.ExecuteIfBound(URL, Description, SharePrompt, LocationHintX, LocationHintY);
 #endif
 
 }

In …/UE4/Source/Editor/MobileInteractionLibrary/Public/MobileInteractionLibraryModule.h


#pragma once
#include "../Source/Runtime/Core/Public/Modules/ModuleManager.h"

DECLARE_LOG_CATEGORY_EXTERN(MobileInteractionLibraryModule, All, All);

class FMobileInteractionLibraryModule : public IModuleInterface
{ public:

/* This will get called when the editor loads the module */
virtual void StartupModule() override;

/* This will get called when the editor unloads the module */
virtual void ShutdownModule() override;
  
 };

And in …/UE4/Source/Editor/MobileInteractionLibrary/Private/MobileInteractionLibraryModule.cpp


#include "MobileInteractionLibraryModule.h"

DEFINE_LOG_CATEGORY(MobileInteractionLibraryModule);

#define LOCTEXT_NAMESPACE "FMobileInteractionLIbraryModule"

void FMobileInteractionLibraryModule::StartupModule()
{
}

void FMobileInteractionLibraryModule::ShutdownModule()
{
}

#undef LOCTEXT_NAMESPACE

IMPLEMENT_MODULE(FMobileInteractionLibraryModule, MobileInteractionLibrary)


Added this as a plugin module instead of a module directly to the Source folder and it worked as expected. Put the changes up as a pull request - if this gets accepted then there will be Blueprint-accessible mobile sharing:

Screenshot 2020-11-05 093533.png