Search Unity

Question Native android UI as a part of Unity VR scene

Discussion in 'VR' started by michalekmarcin, Jan 18, 2023.

  1. michalekmarcin

    michalekmarcin

    Joined:
    Mar 28, 2019
    Posts:
    16
    Hi, I'm trying to display native android view in my VR application. I have additional android studio project in which I extended UnityPlayerActivity. In this project I can compile arr library and add it to Unity project. Everything works after manifest modification for normal 2D application deployed on android phone, but I can't make it work in a VR project.
    I'm developing application for Pico device and I use unity XR and XR interaction toolkit.
     
  2. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    782
    Hi, are you sure its a VR related problem?
    Can you see your "native android view" gameobject in the 3d scene when running the game in the Editor?
     
  3. michalekmarcin

    michalekmarcin

    Joined:
    Mar 28, 2019
    Posts:
    16
    Hi, I can see android view if I deploy my VR app on mobile phone. I think that my overlay is rendered on screen space. That's why I can't see it on Pico VR HMD.
     
  4. michalekmarcin

    michalekmarcin

    Joined:
    Mar 28, 2019
    Posts:
    16
    I'm adding my overlay like this:

    Code (CSharp):
    1. public class MainActivity extends UnityPlayerActivity {
    2.     @Override
    3.     protected void onCreate(Bundle bundle) {
    4.         super.onCreate(bundle);
    5.  
    6.         Log.d("AndroidUI", "Creating FirstFragment");
    7.  
    8.         FirstFragment myOverlayFragment = new FirstFragment();
    9.         FragmentTransaction ft = getFragmentManager().beginTransaction();
    10.  
    11.         ft.add(android.R.id.content, myOverlayFragment).commitNowAllowingStateLoss();
    12.  
    13.         Log.d("AndroidUI", "FirstFragment added");
    14.     }
    15. }