1

Unity 拡張機能を介して AR/インタラクティブ コンテンツに Vuforia を使用するアプリに取り組んでいます。Vuforia を (レンダリング用の Unity と共に) アプリに統合する方法を理解するのに苦労しています。

Android 2.3.3 (API レベル 10) 以降をターゲットにしています。

現在、私のアプリは、いくつかのバックグラウンド タスクを開始し、ViewPager と FragmentPagerAdapter を使用していくつかのフラグメントを切り替える SherlockFragmentActivity があるように設定されています。これらのフラグメントの 1 つが Vuforia フラグメントです。

これまでのところ、UnityPlayer をインスタンス化し、フラグメントの onCreateView でビューを返すことを試みました。

public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    UnityPlayer mPlayer = new UnityPlayer(this); // Put your activity object here
    int glesMode = mPlayer.getSettings().getInt("gles_mode", 1);
    boolean trueColor8888 = false;
    mPlayer.init(glesMode, trueColor8888);
        View view = mPlayer.getView();
        return view;
}

ただし、これを行うと Vuforia のロードに失敗します。Unity は読み込まれますが、黒い画面が表示され、カメラからの出力がありません。ログキャット:

07-02 14:59:25.695: D/Unity(18351): Creating OpenGL ES 2.0 context (RGBA32 8888 24/8)
07-02 14:59:25.900: D/Unity(18351): GL_EXT_debug_marker GL_OES_texture_npot     GL_OES_compressed_ETC1_RGB8_texture GL_OES_standard_derivatives GL_OES_EGL_image GL_OES_depth24 GL_ARM_rgba8 GL_ARM_mali_shader_binary GL_OES_depth_texture GL_OES_packed_depth_stencil GL_EXT_texture_format_BGRA8888 GL_EXT_blend_minmax GL_OES_EGL_image_external GL_OES_EGL_sync GL_OES_rgb8_rgba8 GL_EXT_multisampled_render_to_texture GL_EXT_discard_framebuffer 
07-02 14:59:26.520: D/dalvikvm(18351): Trying to load lib /data/data/com.androchill.socialsquare.fingerprintdemo/lib/libQCARWrapper.so 0x41efb450
07-02 14:59:26.520: E/Unity(18351): Unable to find QCARWrapper
07-02 14:59:26.525: D/dalvikvm(18351): Trying to load lib /data/data/com.androchill.socialsquare.fingerprintdemo/lib/libQCARWrapper.so 0x41efb450
07-02 14:59:26.525: E/Unity(18351): Unable to find QCARWrapper
07-02 14:59:26.750: I/Unity(18351): DllNotFoundException: QCARWrapper
07-02 14:59:26.750: I/Unity(18351):   at (wrapper managed-to-native) QCARNativeWrapper:trackerManagerInitTracker (int)
07-02 14:59:26.750: I/Unity(18351):   at QCARNativeWrapper.TrackerManagerInitTracker (Int32 trackerType) [0x00000] in <filename unknown>:0 
07-02 14:59:26.750: I/Unity(18351):   at TrackerManagerImpl.InitTracker (Type trackerType) [0x00000] in <filename unknown>:0 
07-02 14:59:26.750: I/Unity(18351):   at DataSetLoadBehaviour.Awake () [0x00000] in <filename unknown>:0 
07-02 14:59:26.750: I/Unity(18351):  
07-02 14:59:26.750: I/Unity(18351): (Filename:  Line: -1)
07-02 14:59:26.815: I/Unity(18351): Trackable USC_campus_map lost
07-02 14:59:26.815: I/Unity(18351):  
07-02 14:59:26.815: I/Unity(18351): (Filename: ./Runtime/ExportGenerated/AndroidManaged/UnityEngineDebug.cpp Line: 54)
07-02 14:59:26.815: D/dalvikvm(18351): Trying to load lib /data/data/com.androchill.socialsquare.fingerprintdemo/lib/libQCARWrapper.so 0x41efb450
07-02 14:59:26.815: E/Unity(18351): Unable to find QCARWrapper
07-02 14:59:26.815: D/dalvikvm(18351): Trying to load lib /data/data/com.androchill.socialsquare.fingerprintdemo/lib/libQCARWrapper.so 0x41efb450
07-02 14:59:26.815: E/Unity(18351): Unable to find QCARWrapper
07-02 14:59:26.820: I/Unity(18351): DllNotFoundException: QCARWrapper
07-02 14:59:26.820: I/Unity(18351):   at (wrapper managed-to-native) QCARNativeWrapper:getInitErrorCode ()
07-02 14:59:26.820: I/Unity(18351):   at QCARNativeWrapper.GetInitErrorCode () [0x00000] in <filename unknown>:0 
07-02 14:59:26.820: I/Unity(18351):   at QCARUnityImpl.CheckInitializationError () [0x00000] in <filename unknown>:0 
07-02 14:59:26.820: I/Unity(18351):   at QCARUnity.CheckInitializationError () [0x00000] in <filename unknown>:0 
07-02 14:59:26.820: I/Unity(18351):   at DefaultInitializationErrorHandler.Start () [0x00000] in <filename unknown>:0 
07-02 14:59:26.820: I/Unity(18351):  
07-02 14:59:26.820: I/Unity(18351): (Filename:  Line: -1)
07-02 14:59:26.820: I/Unity(18351): QCARWrapper.Start
07-02 14:59:26.820: I/Unity(18351):  
07-02 14:59:26.820: I/Unity(18351): (Filename: ./Runtime/ExportGenerated/AndroidManaged/UnityEngineDebug.cpp Line: 54)
07-02 14:59:26.825: I/Unity(18351): DllNotFoundException: QCARWrapper
07-02 14:59:26.825: I/Unity(18351):   at (wrapper managed-to-native) QCARNativeWrapper:getInitErrorCode ()
07-02 14:59:26.825: I/Unity(18351):   at QCARNativeWrapper.GetInitErrorCode () [0x00000] in <filename unknown>:0 
07-02 14:59:26.825: I/Unity(18351):   at QCARUnityImpl.CheckInitializationError () [0x00000] in <filename unknown>:0 
07-02 14:59:26.825: I/Unity(18351):   at QCARUnity.CheckInitializationError () [0x00000] in <filename unknown>:0 
07-02 14:59:26.825: I/Unity(18351):   at QCARBehaviour.Start () [0x00000] in <filename unknown>:0 
07-02 14:59:26.825: I/Unity(18351):  
07-02 14:59:26.825: I/Unity(18351): (Filename:  Line: -1)
07-02 14:59:26.855: D/dalvikvm(18351): Trying to load lib /data/data/com.androchill.socialsquare.fingerprintdemo/lib/libQCARWrapper.so 0x41efb450
07-02 14:59:26.855: E/Unity(18351): Unable to find QCARWrapper
07-02 14:59:26.860: D/dalvikvm(18351): Trying to load lib /data/data/com.androchill.socialsquare.fingerprintdemo/lib/libQCARWrapper.so 0x41efb450
07-02 14:59:26.860: E/Unity(18351): Unable to find QCARWrapper
07-02 14:59:26.860: I/Unity(18351): DllNotFoundException: QCARWrapper
07-02 14:59:26.860: I/Unity(18351):   at (wrapper managed-to-native) QCARNativeWrapper:rendererRenderVideoBackground (int)
07-02 14:59:26.860: I/Unity(18351):   at QCARNativeWrapper.RendererRenderVideoBackground (Int32 bindVideoBackground) [0x00000] in <filename unknown>:0 
07-02 14:59:26.860: I/Unity(18351):   at QCARManagerImpl.RenderVideoBackgroundOrDrawIntoTextureInNative () [0x00000] in <filename unknown>:0 
07-02 14:59:26.860: I/Unity(18351):   at QCARManagerImpl.PrepareRendering () [0x00000] in <filename unknown>:0 
07-02 14:59:26.860: I/Unity(18351):   at QCARBehaviour.OnPreCull () [0x00000] in <filename unknown>:0 
07-02 14:59:26.860: I/Unity(18351):  
07-02 14:59:26.860: I/Unity(18351): (Filename:  Line: -1)
07-02 14:59:26.900: D/dalvikvm(18351): Trying to load lib /data/data/com.androchill.socialsquare.fingerprintdemo/lib/libQCARWrapper.so 0x41efb450
07-02 14:59:26.900: E/Unity(18351): Unable to find QCARWrapper
07-02 14:59:26.905: D/dalvikvm(18351): Trying to load lib /data/data/com.androchill.socialsquare.fingerprintdemo/lib/libQCARWrapper.so 0x41efb450
07-02 14:59:26.905: E/Unity(18351): Unable to find QCARWrapper
07-02 14:59:26.905: I/Unity(18351): DllNotFoundException: QCARWrapper
07-02 14:59:26.905: I/Unity(18351):   at (wrapper managed-to-native) QCARNativeWrapper:rendererEnd ()
07-02 14:59:26.905: I/Unity(18351):   at QCARNativeWrapper.RendererEnd () [0x00000] in <filename unknown>:0 
07-02 14:59:26.905: I/Unity(18351):   at QCARManagerImpl.FinishRendering () [0x00000] in <filename unknown>:0 
07-02 14:59:26.905: I/Unity(18351):   at QCARBehaviour.OnPostRender () [0x00000] in <filename unknown>:0 

次に、UnityPlayer の代わりに QCARUnityPlayer をインスタンス化しようとしましたが、UnsatisfiedLinkError が発生します。

07-02 15:04:26.830: I/QCAR(26661): onSurfaceCreated
07-02 15:04:26.830: W/dalvikvm(26661): No implementation found for native Lcom/qualcomm/QCAR/QCAR;.onSurfaceCreated:()V
07-02 15:04:26.860: W/dalvikvm(26661): threadid=14: thread exiting with uncaught exception (group=0x412522a0)
07-02 15:04:26.860: E/AndroidRuntime(26661): FATAL EXCEPTION: GLThread 1638
07-02 15:04:26.860: E/AndroidRuntime(26661): java.lang.Error: FATAL EXCEPTION [GLThread 1638]
07-02 15:04:26.860: E/AndroidRuntime(26661): Unity version     : 4.1.5f1
07-02 15:04:26.860: E/AndroidRuntime(26661): Device model      : samsung GT-N7100
07-02 15:04:26.860: E/AndroidRuntime(26661): Device fingerprint: samsung/t03gxx/t03g:4.1.2/JZO54K/N7100XXDMC3:user/release-keys
07-02 15:04:26.860: E/AndroidRuntime(26661): Caused by: java.lang.UnsatisfiedLinkError: Native method not found: com.qualcomm.QCAR.QCAR.onSurfaceCreated:()V
07-02 15:04:26.860: E/AndroidRuntime(26661):    at com.qualcomm.QCAR.QCAR.onSurfaceCreated(Native Method)
07-02 15:04:26.860: E/AndroidRuntime(26661):    at com.qualcomm.QCARUnityPlayer.QCARUnityPlayer.onSurfaceCreated(QCARUnityPlayer.java:39)
07-02 15:04:26.860: E/AndroidRuntime(26661):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1494)
07-02 15:04:26.860: E/AndroidRuntime(26661):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)

私はこのチュートリアルに従っていますが、他のほとんどすべてのものを見つけることができますが、まだ理解できません.

私のフラグメントコード:

import android.content.res.Configuration;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.actionbarsherlock.app.SherlockFragment;
import com.unity3d.player.UnityPlayer;

public class MyFragment extends SherlockFragment {

private UnityPlayer mUnityPlayer;

// UnityPlayer.init() should be called before attaching the view to a layout. 
// UnityPlayer.quit() should be the last thing called; it will terminate the process and not return.

public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    mUnityPlayer = new UnityPlayer(getActivity()); // Put your activity object here
    int glesMode = mUnityPlayer.getSettings().getInt("gles_mode", 1);
    boolean trueColor8888 = false;
    mUnityPlayer.init(glesMode, trueColor8888);

    // Get the view - e.g. to return from the fragment method onCreateView:
    View view = mUnityPlayer.getView();
    return view;
}

public void onDestroy()
{
    super.onDestroy();
    mUnityPlayer.quit();
}

// onPause()/onResume() must be sent to UnityPlayer to enable pause and resource recreation on resume.
public void onPause()
{
    super.onPause();
    mUnityPlayer.pause();
    if (getActivity().isFinishing())
        mUnityPlayer.quit();
}
public void onResume()
{
    super.onResume();
    mUnityPlayer.resume();
}
public void onConfigurationChanged(Configuration newConfig)
{
    super.onConfigurationChanged(newConfig);
    mUnityPlayer.configurationChanged(newConfig);
}

// Pass any keys not handled by (unfocused) views straight to UnityPlayer
public boolean onKeyMultiple(int keyCode, int count, KeyEvent event)
{
    return mUnityPlayer.onKeyMultiple(keyCode, count, event);
}
public boolean onKeyDown(int keyCode, KeyEvent event)
{
    return mUnityPlayer.onKeyDown(keyCode, event);
}
public boolean onKeyUp(int keyCode, KeyEvent event)
{
    return mUnityPlayer.onKeyUp(keyCode, event);
}
}

私の質問は、Unity/Vuforia を SherlockFragment で強制的に動作させるにはどうすればよいですか?

4

0 に答える 0