- Home /
Question by
zaidpc0462 · Dec 04, 2020 at 04:07 PM ·
buttonbutton trigger events
onpointerdown not working i just made a script for my cube to move left but its not moving i dint done anything just made this script and attached to the cube
this is the script
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI;
public class LeftButton : MonoBehaviour { public bool TurnLeft = false;
public GameObject Cube;
public void OnPointerDown(PointerEventData eventData)
{
TurnLeft = true;
Debug.Log("Clicked");
}
public void OnPointerUp(PointerEventData eventData)
{
TurnLeft = false;
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (TurnLeft == true)
{
Cube.transform.Translate(Vector3.left * Time.deltaTime * 7);
}
}
}
Comment