Hey guys im really new in what comes to Unity.
I'm trying to make some drum pads to have individual sound that when you press and hold it it will loop. So far i got to this script but i can't make it work individually for each button. Instead when i add it to a button whenever i click in the screen it will play it. Any idea of what should i do?
using UnityEngine;
using System.Collections;
public class playSound : MonoBehaviour {
public AudioSource mySound;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.Mouse0))
{
mySound.enabled = true;
mySound.loop = true;
}
else
{
mySound.enabled = false;
mySound.loop = false;
}
}
}
↧