Search Unity

SetVREnabledOnTargetGroup / not always working / Cardboard issue

Discussion in 'AR/VR (XR) Discussion' started by plmx, Jun 12, 2018.

  1. plmx

    plmx

    Joined:
    Sep 10, 2015
    Posts:
    250
    Hi all,

    I am attempting to switch Virtual Reality SDKs from an editor script, due to support for different platforms; for example:

    Code (CSharp):
    1.  
    2. UnityEditorInternal.VR.VREditor.SetVREnabledOnTargetGroup(androidTG, true);
    3. UnityEditorInternal.VR.VREditor.SetVREnabledDevicesOnTargetGroup(androidTG, new string[] { "Cardboard"});
    Now, the first issue is that this doesn't work in every case; i.e. sometimes the enabled device simply does not change (for example from Oculus to Cardboard). A debug log shows that I am setting the correct name. I have the slight feeling that this has to do with whether the Player settings view is open at the point of the change. Can anyone confirm this behavior? If this is the case (which I'd consider a bug), can I programmatically close the PlayerSettings window before setting the enabled VR devices?

    The second issue I have here is that if I set the vr enabled devices to "Cardboard", what will happen is that I get "Cardboard (missing from build)" instead of simply "Cardboard". If I remove this and (manually) add Cardboard again, the "missing from build" part disappears. So, it seems that I am missing something here, is there another way to set the enabled VR devices?

    Thanks.

    Philip
     
  2. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    567
    What version of Unity are you using?
     
  3. plmx

    plmx

    Joined:
    Sep 10, 2015
    Posts:
    250
    @joejo Thanks for your response. I am using 2018.1.2f1 (Pro, if this makes any difference).
     
    Last edited: Jun 12, 2018
  4. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    567
    Please file a bug using a simple repro project and post the case id back here. Thank you.
     
  5. plmx

    plmx

    Joined:
    Sep 10, 2015
    Posts:
    250
    @joejo Thanks for your answer. I have filed a bug for the second issue I was having, i.e. the "Cardboard (missing from build)" problem. The case id is 1048637. Thank you for looking into this.

    My first issue has since been resolved: The PlayerSettings indeed do show the correct values in separate tabs which are switched when changing the selected platform in the build window, not the actually active platform (which is indicated by the Unity icon). This created a lot of confusion for me. However, I since found the two additional properties below, which also change the selected platform.

    Code (CSharp):
    1.  
    2. EditorUserBuildSettings.selectedBuildTargetGroup = BuildTargetGroup.Android;
    3. EditorUserBuildSettings.selectedStandaloneTarget = BuildTarget.Android;
    So, I'm leaving this here in case anyone else runs into this.
     
  6. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    567
    Thank you.