dopeman
New Member
Posts: 3
Posts: 3
|
Post by dopeman on Dec 3, 2020 5:56:41 GMT
Hey, I'm using MAAA to play sounds when I click a button. Tried using ButtonClicker.cs but using a VR controller (not mouse) so I wrote small script that grabs the event and ... I would like to have a dropdown when selecting the sound group. How can I do this. In brief, how do I go from this ibb.co/61bxJgsto this
P.S. I do not like working with strings.
Attachments:
|
|
|
Post by DarkTonic Dev on Dec 3, 2020 17:03:07 GMT
Looks like it's working correctly to me, and you only have one Sound Group, with a really long name.
There's nothing wrong with strings.
|
|
dopeman
New Member
Posts: 3
Posts: 3
|
Post by dopeman on Dec 4, 2020 1:14:19 GMT
My question is how do I get this "autocomplete" functionality? I'm using ButtonClicker.cs as a reference but there is some magic happening that adds the autocomplete functionality.
|
|
|
Post by DarkTonic Dev on Dec 4, 2020 4:00:01 GMT
Autocomplete refers to when you are typing and it tries to complete what you're typing by offering you choices. Are you referring to that? We have not provided that, nor know how to.
This is supposed to show a dropdown and you use the mouse to select.
|
|
dopeman
New Member
Posts: 3
Posts: 3
|
Post by dopeman on Dec 4, 2020 4:56:05 GMT
I apologise if my query is unclear. I have made a script that (1) grabs the Button.onClick event and (2) plays a sound when the button is clicked. using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using DarkTonic.MasterAudio;
namespace DarkTonic.MasterAudio { [RequireComponent(typeof(Button))] public class SoundOnClick : MonoBehaviour { Button btn; public AudioClip onClickSound; public string maaaGroup ="ButtonClickSoundGroup"; // Start is called before the first frame update void Start() { btn = GetComponent<Button>(); btn.onClick.AddListener(PlayMasterAudio); }
void PlaySound() { AudioSource.PlayClipAtPoint(onClickSound, transform.position); Debug.Log("Play Sound"); } void PlayMasterAudio() { if(enabled){ MasterAudio.PlaySoundAndForget(maaaGroup); } } } } - I would like to select maaaGroup by dropdown, thereby saving me the risk of typing in the string incorrect.
- Is this the correct way of doing it? I am using ButtonClicker.cs as a guide.
I appreciate the quick response time.
|
|
|
Post by DarkTonic Dev on Dec 4, 2020 5:44:16 GMT
Ah, you need to decorate your public string with the SoundGroup attribute so that dropdown will show up. Like this.
[SoundGroup] public string buttonClickSound;
ButtonClicker may have a custom Inspector and not be able use the attributes, I forget. That is true of most of our scripts.
|
|