NOTE (just tried): Given what I'm doing below (using getView() in place of view, and leaving the rootView return as is..i.e. inflate and return) I do get something now in the emulator. I get my app with Actionbar, and the Vuforia sample (Vuforia Buttons) starts to come up...the splash screen then the About page... However, I cannot get any buttons to work. In other words, the About screen stays put, hitting the OK button on it, doesn't dismiss it, so I'm not sure if the camera will come up or not (yet).
Did you see this behavior? Or did you just avoid the Vuforia UI screens completely?
Am I doing the fragment correctly? (I'm using themes so am using ActionBar and app compatible theme settings...perhaps that is causing the problems?)
-----------original reply-------------
Hi, sorry to be so stupid about this.
OK, I've modified the basic android activity with one fragment example...
....or am in the process again per your instructions (so now my activity and frame layout are simple framelayouts with the ids container and unity_container...
....and added that to my working code (basic google project from unity).
Given that, here's the basic generated fragment...with your code injected between...
note: In your call to find the unity_container FrameLayout container = (FrameLayout)view.findViewById(R.id.unity_container);
the view doesn't resolve...I tried using rootView...but I'm not sure if one should even inflate the rootview or return it...but I can't figure out what 'view' should be in order to find the container in this situation. (can't use PlaceholderFragment.this, or MainActivity.this) However, getView() should work, but stil not sure what exactly that will do in this case, and I still am not sure what I should return from onCreateView?
Second question, do you still use <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" /> in the mainfest for the main activity? (i.e. TRUE not false?) (and use that same long manifest that is generated by the unity/vuforia google project?)
Again, sorry to be so dumb on this...perhaps it's lack of sleep by this point.
Cynthia
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_main, container, false);
mUnityPlayer = new UnityPlayer(getActivity());
final int mode = mUnityPlayer.getSettings().getInt("gles_mode", 1);
this.mQCARShared = new QCARPlayerSharedActivity();
this.mQCARShared.onCreate(getActivity(), mode, new QCARPlayerSharedActivity.IUnityInitializer() {
@Override
public void InitializeUnity() {
mUnityPlayer.init(mode, false);
FrameLayout container = (FrameLayout)view.findViewById(R.id.unity_container);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
container.addView(mUnityPlayer, 0, lp);
mUnityPlayer.windowFocusChanged(true);
mUnityPlayer.resume();
}
});
return rootView;
}
}
This probably isn't possible with the default samples, which render the video background under the hood. You may want to try with the BackgroundTextureAccess sample, however. This sample renders the camera image in Unity using a standard Texture2D object.
Also note that you will need to extend the QCAR-specific activities. See this threads for some tips:
http://ar.qualcomm.at/node/2001243
Please note this isn't something we have tested. Let us know how it works!
- Kim