Quantcast
Channel: Questions in topic: "hold"
Viewing all articles
Browse latest Browse all 154

How to play loop an audio clip on button hold down?

$
0
0
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; } } }

Viewing all articles
Browse latest Browse all 154

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>