0

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 Answer 1

0

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);
        }
    }

}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.