- Home /
Question by
BlackVelvet · Apr 12, 2020 at 08:48 AM ·
c#sounduser interfacechecking
Get text from UI when collected play sound.
Hi everyone, I'm having a bit of trouble. The "spokenword" should find a string from UI text. I have multiple objects than when collected form a word (word is generated randomly from a pool), this should check what word is collected and then play the corresponding sound with the same name. I hope this makes sense.
public class SpokenWord : MonoBehaviour {
public string spokenword;
private void Start()
{
}
private void OnTriggerEnter(Collider other)
{
if (other.name == "Player")
{
FindObjectOfType<AudioManager>().Play(spokenword);
}
Destroy(gameObject);
}
private void OnTriggerExit(Collider other)
{
other.gameObject.SetActive(false);
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612231158im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
is it posible to import a sound from youtube to unity 1 Answer
how can mute all sounds in the Scene? 1 Answer
Sound not playing 1 Answer