简体   繁体   English

使用 Android 插件:在基础 'JNISingleton' 中不存在 function 'getPluginName'

[英]Using Android Plugin: Nonexistent function 'getPluginName' in base 'JNISingleton'

Godot version: 3.2.3戈多版本: 3.2.3

Issue description: I am new at using Android Plugins in Godot, so I created this simple plugin with only one method.问题描述:我不熟悉在 Godot 中使用 Android 插件,所以我只用一种方法创建了这个简单的插件。

public class GodotProva extends GodotPlugin
{
    public GodotProva(Godot godot) {
        super(godot);
    }

    @NonNull
    @Override
    public String getPluginName() {
        return "mylibrary";
    }
}

I tried to use it in Godot, with the following code:我尝试在 Godot 中使用它,代码如下:

func _pressed():
    if Engine.has_singleton("mylibrary"):
        var singleton = Engine.get_singleton("mylibrary")
                print(singleton.getPluginName())

I created an apk and installed it on my Android device.我创建了一个 apk 并将其安装在我的 Android 设备上。 The problem is that when I press the button (and the function _pressed() is called), I can see from the logcat the error Nonexistent function 'getPluginName' in base 'JNISingleton'问题是当我按下按钮时(并且调用了 function _pressed()),我可以从 logcat 中看到错误Nonexistent function 'getPluginName' in base 'JNISingleton'

I am sure that the plugin is found, because the "singleton" variable is not null.我确定找到了插件,因为“单例”变量不是 null。 What am I doing wrong?我究竟做错了什么?

I found out that in Godot I can only call custom functions.我发现在 Godot 中我只能调用自定义函数。 The methods of the class GodotPlugin (such as getPluginName, getPluginMethods...) cannot be directly called. class GodotPlugin的方法(如getPluginName、getPluginMethods...)不能直接调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM