| | 1 | | using UnityEngine; |
| | 2 | |
|
| | 3 | | namespace DCL |
| | 4 | | { |
| | 5 | | public class DCLVoiceChatController : MonoBehaviour |
| | 6 | | { |
| | 7 | | [Header("InputActions")] |
| | 8 | | public InputAction_Hold voiceChatAction; |
| | 9 | | public InputAction_Trigger voiceChatToggleAction; |
| | 10 | |
|
| | 11 | | private InputAction_Hold.Started voiceChatStartedDelegate; |
| | 12 | | private InputAction_Hold.Finished voiceChatFinishedDelegate; |
| | 13 | | private InputAction_Trigger.Triggered voiceChatToggleDelegate; |
| | 14 | |
|
| | 15 | | void Awake() |
| | 16 | | { |
| 116 | 17 | | voiceChatStartedDelegate = (action) => DCL.Interface.WebInterface.SendSetVoiceChatRecording(true); |
| 116 | 18 | | voiceChatFinishedDelegate = (action) => DCL.Interface.WebInterface.SendSetVoiceChatRecording(false); |
| 116 | 19 | | voiceChatToggleDelegate = (action) => DCL.Interface.WebInterface.ToggleVoiceChatRecording(); |
| 116 | 20 | | voiceChatAction.OnStarted += voiceChatStartedDelegate; |
| 116 | 21 | | voiceChatAction.OnFinished += voiceChatFinishedDelegate; |
| 116 | 22 | | voiceChatToggleAction.OnTriggered += voiceChatToggleDelegate; |
| | 23 | |
|
| 232 | 24 | | KernelConfig.i.EnsureConfigInitialized().Then(config => EnableVoiceChat(config.comms.voiceChatEnabled)); |
| 116 | 25 | | KernelConfig.i.OnChange += OnKernelConfigChanged; |
| 116 | 26 | | } |
| | 27 | | void OnDestroy() |
| | 28 | | { |
| 115 | 29 | | voiceChatAction.OnStarted -= voiceChatStartedDelegate; |
| 115 | 30 | | voiceChatAction.OnFinished -= voiceChatFinishedDelegate; |
| 115 | 31 | | KernelConfig.i.OnChange -= OnKernelConfigChanged; |
| 115 | 32 | | } |
| | 33 | |
|
| 10 | 34 | | void OnKernelConfigChanged(KernelConfigModel current, KernelConfigModel previous) { EnableVoiceChat(current.comm |
| | 35 | |
|
| 242 | 36 | | void EnableVoiceChat(bool enable) { CommonScriptableObjects.voiceChatDisabled.Set(!enable); } |
| | 37 | | } |
| | 38 | | } |