Search Unity

Unity VR daydream Pointer doesn`t trigger .Onclick() button Event.

Discussion in 'AR/VR (XR) Discussion' started by ShadownHeart, Mar 8, 2017.

  1. ShadownHeart

    ShadownHeart

    Joined:
    Oct 8, 2015
    Posts:
    29
    Hi!
    As the tittle sugest, I'm implementing this method that has as a param a UnityAction,
    Code (csharp):
    1.  
    2. public void addDialogTriggerAction(int optionNumber, string boxDialog, UnityAction dialogTriggerEvent) {
    3.         interactionMenuObject.SetActive (true);
    4.         dialogGameObject [optionNumber].SetActive (true);
    5.         dialogButton[optionNumber].onClick.RemoveAllListeners();
    6.         dialogButton [optionNumber].onClick.AddListener(dialogTriggerEvent);
    7.         dialog[optionNumber].text = boxDialog;
    8.         //iconImage[optionNumber].sprite = dialogIcon;
    9.     }
    10.  
    The problem seems as if the daydream controller cannot trigger the .OnClick() event of the button, it only triggers events of EventTrigger component.
    I need this structure for a dynamic menu content so I can change the menu text and actions methods on the fly.
    [Example]:
    Reusable contextual menu for a multiple dialog option panel. You could change the text and the reaction of an NPC you are talking to each time he/she/it asked you a question with this structure.
    Any sugestion?
     
  2. mira_leung

    mira_leung

    Official Google Employee

    Joined:
    May 17, 2016
    Posts:
    70
    Try checking for GvrController.ClickButton or GvrController.ClickButton{Up,Down} instead.
     
  3. dsternfeld

    dsternfeld

    Official Google Employee

    Joined:
    Jan 3, 2017
    Posts:
    72
    I've just verified in a simple sample scene that I was able to respond to Button.OnClick events while using GvrEventSystem and GvrControllerPointer.

    If you send me a simple sample project that reproduces the bug, I would be happy to take a look at what is causing the issue.

    Thanks,

    Dan
     
  4. ShadownHeart

    ShadownHeart

    Joined:
    Oct 8, 2015
    Posts:
    29
    Hi! Thanks for the answer!
    I had linked a sample project with the issue. I'm using the remote controller app on mobile for testing and something interesting happens: if for any reason the app doesn´t detect the mobile as the controller It can still trigger the touch click button, and in that situation It triggers the OnClick event. But if the app functions correctly it will not trigger no matter what.
    https://www.dropbox.com/sh/jlw8clt2d2ou60n/AAC6pfUS2bkdmMuuh6A4zE9Na?dl=0

    TestProject: When you run the scene, a script will activate the option panels and change the text and .onClick() action of the button.
    - (GameObject) OptionPanel has the script that change the text and action.
     
    Last edited: Mar 9, 2017
  5. dsternfeld

    dsternfeld

    Official Google Employee

    Joined:
    Jan 3, 2017
    Posts:
    72
    Hey there!

    I checked out your example project, and was able to get Button.OnClick to fire by removing the EventTrigger script on the parent. I believe that what is happening is that the EventTrigger is consuming the PointerClick event which prevents the Button from receiving the PointerClick event.

    In the documentation for EventTrigger, there is a note that says this the following:

    Thanks,

    Dan
     
  6. ShadownHeart

    ShadownHeart

    Joined:
    Oct 8, 2015
    Posts:
    29
    Okey! That worked perfectly! Thanks!
    I changed the eventTrigger component to the actual button where the .OnClick() function was, and now it triggers! Next time I will pay more attention to the documentation!
     
  7. dennisbonilla

    dennisbonilla

    Joined:
    Jun 15, 2016
    Posts:
    1
    The way I did it was to extend my class to include:
    Code (CSharp):
    1. IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
    So the code below worked for me. I should also note that this only worked for the Google Daydream controller.
    Code (CSharp):
    1.  
    2. public class SomeClass : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
    3. {
    4.  
    5.   public void OnPointerEnter(PointerEventData eventData)
    6.   {
    7.     Debug.Log("Entered " + gameObject.name);
    8.   }
    9.  
    10.   public void OnPointerExit(PointerEventData eventData)
    11.   {
    12.     Debug.Log("Exited " + gameObject.name);
    13.   }
    14.  
    15.   public void OnPointerClick(PointerEventData eventData)
    16.   {
    17.     Debug.Log(gameObject.name + " clicked");
    18.   }
    19. }
    20.  
     
  8. s3519064

    s3519064

    Joined:
    Aug 25, 2017
    Posts:
    3
     
  9. s3519064

    s3519064

    Joined:
    Aug 25, 2017
    Posts:
    3
    Which object should you add this script to?
     
  10. Team21Dev

    Team21Dev

    Joined:
    Apr 2, 2017
    Posts:
    6
    i love all these half answers