Hey guys, been working on a minigame for days.
I readapted this AMAZING turorial:
As you can see, on screen buttons are mapped to the keyboard keys (Arrows Left, Up, Down, Right).
My idea is to adapt this controls to Touch devices… so touching buttons (first image) can be taped as normal with the finger.
could anyone please help?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ButtonController : MonoBehaviour
{
private SpriteRenderer theSR;
public Sprite defaultImage;
public Sprite pressedImage;
public KeyCode keyToPress;
void Start()
{
theSR = GetComponent<SpriteRenderer>();
}
void Update()
{
if(Input.GetKeyDown(keyToPress))
{
theSR.sprite = pressedImage;
}
if (Input.GetKeyUp(keyToPress))
{
theSR.sprite = defaultImage;
}
}
}