Answer the question
In order to leave comments, you need to log in
Why is the button not responding to clicks?
In general, according to the video, I wrote the following script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class buttonClick : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
public void OnPointerDown(PointerEventData eventData) {
if(gameObject.name == "right") {
GameObject.FindWithTag("Player").GetComponent<Player>().move = 1;
}else if(gameObject.name == "left") {
GameObject.FindWithTag("Player").GetComponent<Player>().move = -1;
}
Debug.Log(GameObject.FindWithTag("Player").GetComponent<Player>().move);
}
public void OnPointerUp(PointerEventData eventData) {
GameObject.FindWithTag("Player").GetComponent<Player>().move = 0;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question