How to assign event trigger pointer click as Fire1 in Google VR Cardboard Unity 2019

779 views Asked by At

I've finish my VR Cardboards game using Unity 2019 but the problem is I forgot to declare every click action with controller with Input.GetKeyDown("Fire1"). I was assigned all click-event with event trigger Pointer Click. So I can't play this game with controller.

Example of Event Trigger Pointer Click There's any way to get me out from this?

1

There are 1 answers

0
Gerry Jeven Timoti On

Case closed by myself. Use this script and put to the interactable object with pointer click.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

public class PointerTrigger : MonoBehaviour, IPointerEnterHandler,IPointerExitHandler
{
    bool active = false;
    public void OnPointerEnter(PointerEventData eventData)
    {
        active = true;
    }

    public void OnPointerExit(PointerEventData eventData)
    {
        active = false;
    }


    private void Update()
    {

        if (active && Input.GetButtonDown("Fire1"))
        {
            Debug.Log("Fired");

            var pointer = new PointerEventData(EventSystem.current);
            ExecuteEvents.Execute(gameObject, pointer, ExecuteEvents.pointerClickHandler);
        }
    }

}