简体   繁体   English

Unity 中的原生 C++ 和 Java Android 库

[英]Native C++ and Java Android Library in Unity

I have a native android library that I am trying to use from the Unity Edtor.我有一个我试图从 Unity Edtor 使用的本机 android 库。 The library is compiled into and aar file, and has both C++ and Java code.该库被编译成aar文件,并且有C++和Java代码。 I have placed the AAR file inside the plugins folder and it works fine on the device, but does not work on the editor.我已将 AAR 文件放在 plugins 文件夹中,它在设备上运行良好,但在编辑器上不起作用。

On the editor, I can successfully instantiate an AndroidJavaObject, but when I try to call one of its functions that return a string, I get a null.在编辑器上,我可以成功实例化一个 AndroidJavaObject,但是当我尝试调用它的一个返回字符串的函数时,我得到一个空值。 This works fine on the target device, but I need it work on the editor for debugging purposes.这在目标设备上工作正常,但我需要它在编辑器上工作以进行调试。

Do I have to set the JNI path by any chance for it to work?我是否必须通过任何机会设置 JNI 路径才能使其工作? Do I have to have it in a different format like a .so?我是否必须使用不同的格式,如 .so?

Thanks in advance提前致谢

不幸的是这是不可能的,Unity Editor 不提供此功能,请使用真实设备或模拟器。

如果你没有找到其他方法让它工作,并且实际上并不需要来自实际设备的输出(因为你在编辑器上运行它......)也许你应该只是模拟它 -编辑器使用:无论你在哪里调用插件方法,只要有一个#if Unity_Editor mock #else call #endif

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

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