Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

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:
    15
    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:
    775
    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:
    15
    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:
    15
    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. }