x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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 d0d0

Here is a sceenshot of this function visible in BluePrint: alt text

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
 
 
 
 


Product Version: UE 4.13
Tags:
more ▼

asked Dec 08 '16 at 07:27 PM in C++ Programming

avatar image

d0d0
482 17 9 18

avatar image theonecalledtom Dec 14 '16 at 10:40 PM

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?

-Tom

avatar image d0d0 Dec 19 '16 at 06:30 PM

Hi Tom,

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 Analytics 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 d0d0

avatar image HangarSeason Dec 20 '16 at 09:31 AM

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: https://docs.unrealengine.com/latest/INT/Programming/Plugins/ "Module Descriptors" section towards the bottom.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Dec 08 '16 at 10:03 PM

avatar image

Chris Babcock STAFF
1k 11 110 35

avatar image d0d0 Dec 09 '16 at 12:43 AM

Hi Chris,

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 d0d0

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question