【发布时间】:2017-06-19 23:26:20
【问题描述】:
使用$ adb logcat -s "app" 和$ adb logcat -s Unity 查看我在Terminal 中的调试消息,我注意到我的JAR 文件仅在我第一次 时被查询一次 > 将我的应用程序构建到Android (.APK) 但之后每次我只是run 我的应用程序,插件JAR 文件不会被咨询。这是为什么呢?
public class MyClass
{
public static void MyMethod()
{
Log.i("app", "MyMethod entered");
if (blah)
{
Log.d("app", "If entered");
}
else
{
Log.e("app", "Else entered");
}
blah
}
}
使用$ adb logcat -s "app" 我看到Log.i 和Log.d 消息,在我的Unity3D 代码下面,我看到Debug.Log 消息使用$ adb logcat -s Unity
public class MyUnityClass : MonoBehaviour
{
public static void MyUnityMethod()
{
#if UNITY_ANDROID
try
{
using ( AndroidJavaObject androidJavaObject = new AndroidJavaObject("com.example.unityplugin.MyClass") )
{
if (androidJavaObject != null)
{
androidJavaObject.CallStatic("MyMethod");
Debug.Log("androidJavaObject != null SUCCESS!");
}
}
}
catch (Exception e)
{
Debug.LogException(e);
}
#endif
}
}
每次我在平板电脑上运行我的应用程序时,一个脚本会调用MyUnityMethod(),而该脚本又会调用我的JAR 中的MyMethod(),但在第一次构建之后,我再也看不到那些调试消息了...
【问题讨论】:
标签: android unity3d jar logcat