I am new to ArCore and using ArFragment. I want to show my "menu" view when the planes are detected and hide this loading image.
I used "arFragment.getArSceneView.getScene().setOnUpdateListener". Whenever I implement my own "setOnUpdateListener",I am able to show my menu but this loading image does not hide. This image only hides automatically when I do not implement the updateListener. Here is the fragment from activity_main.xml and listener from MainActivity.java
<fragment android:name="com.google.ar.sceneform.ux.ArFragment"
android:id="@+id/ux_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
ArSceneView arSceneView =arFragment.getArSceneView();
arSceneView.getScene().setOnUpdateListener(
frameTime -> {
Frame frame = arSceneView.getArFrame();
if (frame == null) {
return;
}
if (frame.getCamera().getTrackingState() != TrackingState.TRACKING) {
return;
}
for (Plane plane : frame.getUpdatedTrackables(Plane.class)) {
if (plane.getTrackingState() == TrackingState.TRACKING) {
Log.e("********************","");
hsv.setVisibility(View.VISIBLE);
}
}
});
You can work around having the plane discovery view always show on startup by hiding the view, then setting it to null so it won't reappear. In onCreate()
add:
arFragment = (ArFragment)
getSupportFragmentManager().findFragmentById(R.id.ux_fragment);
arFragment.getPlaneDiscoveryController().hide();
arFragment.getPlaneDiscoveryController().setInstructionView(null);