Placeholder-Software / Dissonance

Unity Voice Chat Asset
70 stars 5 forks source link

No way to modify Push to Talk #133

Closed aldo-leka closed 5 years ago

aldo-leka commented 5 years ago

I need to add a button on mobile for Push to Talk but it is bound to Input.axis which does not work with Unity's UI system. I need a way to enable and disable the microphone depending on a UI toggle. How can I do that?

martindevans commented 5 years ago

There are two ways of doing this:

Channels

The VoiceBroadcastTrigger ultimately just opens and closes Channels which control who you are transmitting voice to. So you could write your own trigger which monitors your button and opens/closes the channels as necessary. There's a tutorial on channels here.

Modify VoiceBroadcastTrigger

Alternatively if you go to Assets/Plugins/Dissonance/VoiceBroadcastTrigger.cs around line 369 you will find private bool IsUserActivated() - this method returns a bool to indicate if the user wants to transmit speech (Push-To-Talk is pressed, Voice-Detection is active etc). You can modify this, either by replacing the code inside the case CommActivationMode.PushToTalk: case, or by adding a new branch for something like CommActivationMode.ToggleUiToTalk. I would recommend this approach.

Hopefully that resolve your issue, please close this issue if so :)