Search Unity

Question UI button triggers not functional in build, but work as intended in editor

Discussion in 'VR' started by VCUMCL, Aug 26, 2022.

  1. VCUMCL

    VCUMCL

    Joined:
    Jun 5, 2017
    Posts:
    24
    I am currently working to translate a VR game to the Oculus Quest 2 from a PC standalone version. In this game, I have created a VR menu with UI buttons that include triggers. These triggers have a script attached that when touched by the player, it will simulate the button being clicked.

    Code (CSharp):
    1. private void OnTriggerEnter(Collider other)
    2.     {
    3.         if (other.gameObject.name == "LeftHandAnchor" || other.gameObject.name == "RightHandAnchor")
    4.         {
    5.             this.GetComponent<Button>().onClick.Invoke();
    6.         }
    7.     }
    This works as intended in the Unity Editor, however, when I build the game, none of the triggers work as the should. I am unsure what the reason could be.
     
  2. VCUMCL

    VCUMCL

    Joined:
    Jun 5, 2017
    Posts:
    24
    I have adjusted the above code so that instead of looking for the objects named
    LeftHandAnchor
    and
    RightHandAnchor
    , I replaced these lines to look for tags instead.

    Code (CSharp):
    1. private void OnTriggerEnter(Collider other)
    2.     {
    3.         if (other.gameObject.tag == "VRController" || other.gameObject.tag == "LeftHand" || other.gameObject.tag == "RightHand")
    4.         {
    5.             this.GetComponent<Button>().onClick.Invoke();
    6.         }
    7.     }
    Just as before, however, this works only in the editor and not in the .apk build.
     
  3. VCUMCL

    VCUMCL

    Joined:
    Jun 5, 2017
    Posts:
    24
    So I decided to abandon the box colliders for the menu items and implemented the OVR Laser Pointer that is included in the Oculus Integration package. This allows me to access each menu item without needing to put colliders on them. The main issue I am having is with the Start Level button on this menu screen.



    The Start Level button works as intended in the editor, however it does not function in the build version. Somehow, every other button functions as it should, which is baffling.
     
  4. badradio

    badradio

    Joined:
    Oct 1, 2019
    Posts:
    2
    Hey! Did you solve it? I am facing the same. Text will trigger fine in the editor, but won`t show in the built apk (Oculus Quest)
     
  5. nilagard

    nilagard

    Joined:
    Jan 13, 2017
    Posts:
    77
    Just a question, is the build target JUST for Android or are you also suffering the same bugs in PC build with link/airlink cable also? And do you install the android build onto the headset and trying it as standalone or are you launching the android build from the pc?