unable to execute a Ufunction from a blueprint

Hi,

Need your help figuring this out.

I have a Plugin that has a c++ class deriving from a UObject with a UFunction in it. This UFunction is declared as static and I can see this Ufunction from a blueprint. For some reason, I can’t see this function being executed.

Thanks

Here is a sceenshot of this function visible in BluePrint:

Here is my header code:

// Copyright 1998-2016 HazardNetworking, Inc. All Rights Reserved.

#pragma once


#if PLATFORM_ANDROID
	#include <jni.h>
	#include "Android/AndroidJNI.h"
	#include "Android/AndroidJava.h"
	#include "Android/AndroidApplication.h"
	#include <Android/asset_manager.h>
	#include <Android/asset_manager_jni.h>

#endif


#include "MyPluginObject.generated.h"


//General Log
DECLARE_LOG_CATEGORY_EXTERN(KarmikLog, Log, All);


UCLASS(Blueprintable, BlueprintType )
class UMyPluginObject : public UObject
{
	GENERATED_UCLASS_BODY()

public:
	
	UFUNCTION( BlueprintCallable, BlueprintPure, Category = Karmik)
	static	FString callMapsActivity(FString hazardID, FString hazardDescription );
		

#if PLATFORM_ANDROID
    
	static	 void  AndroidThunkCpp_callMapsActivity();
#endif

private:

	UPROPERTY()
	FMyPluginStruct MyStruct;

};

Here is my source file:

// Copyright 1998-2016 HazardNetworking, Inc. All Rights Reserved.

#include "UObjectPluginPrivatePCH.h"
#include "MyPluginObject.h"


#if PLATFORM_ANDROID
	#include <jni.h>
	#include "Android/AndroidJNI.h"
	#include "Android/AndroidJava.h"
	#include "Android/AndroidApplication.h"
	#include <Android/asset_manager.h>
	#include <Android/asset_manager_jni.h>

#endif


//General Log
DEFINE_LOG_CATEGORY(KarmikLog);
 

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

// This is being called from the BluePrint
FString UMyPluginObject::callMapsActivity(FString hazardID, FString hazardDescription )
{
	
 AndroidThunkCpp_callMapsActivity()
	
#if PLATFORM_ANDROID
	
	UE_LOG(KarmikLog, Warning, TEXT("Calling method: AndroidThunkCpp_callMapsActivity"));
	 AndroidThunkCpp_callMapsActivity();
	 
#endif
	 
     return "Called JNI method: AndroidThunkCpp_callMapsActivity";
	 
	 
}

#if PLATFORM_ANDROID

	
void UMyPluginObject::AndroidThunkCpp_callMapsActivity()
{
	// This will call the java method to invoke MapsActivity
   if (JNIEnv* Env = FAndroidApplication::GetJavaEnv())
   {
  // Do Something
   }
	
}


#endif

Did you mean to leave line 31 in? I would start by moving the UE_LOG out and see if you see it on PC.

Hi ,

Yes I did mean to line 31. This is a method that calls a function in my GameActivity.Java. I took out the function definition as I thought that it was not relevant to this issue. I wanted to see if this function was being executed and so I used UE_LOG, but as you said, I removed it. Looks like the method still doesn’t execute.

Not sure what to do.

Thanks

Do plugins work outside the editor? When I looked into them some time back it seemed they were editor only and code that was executed on the client was all in the exe. I’ll admit to not having looked very deep at the time!

If they do are there any advantages if you are not trying to build some highly modable experience?

Hi ,

Thanks for your reply. I thought that plugins did work outside the editor, but now after you bring up this question, I am not so sure anymore.

I had looked into this plugin GA and this plugin seemed to work outside the editor. I then decided that I would build a plugin instead. Also, plugins seem like a more organized way to build my project. But for some reason, I can’t get it to work.

Anyways, I did port my code into c++ classes outside the plugin and I am able to get it to work. I am able to trigger Java functions from blueprints thru JNI.

Thanks

As far as I understand, the Type variable within Module descriptors defines which circumstances that module is loaded for. “Editor” modules will only be built for the editor, whereas “Runtime” plugins will be loaded in all circumstances, including shipping.

Source: Plugins | Unreal Engine Documentation “Module Descriptors” section towards the bottom.