using UnityEngine; using Normal.Realtime; public class HeadphoneToggleBridge : MonoBehaviour { private HeadphoneVisibilitySync headphoneSync; private void Start() { InvokeRepeating(nameof(FindHeadphoneSync), 0f, 1f); } private void FindHeadphoneSync() { var avatarManager = FindObjectOfType(); if (avatarManager != null && avatarManager.localAvatar != null) { headphoneSync = avatarManager.localAvatar.GetComponentInChildren(); if (headphoneSync != null) CancelInvoke(nameof(FindHeadphoneSync)); } } public void ToggleMyHeadphones() { if (headphoneSync != null) { headphoneSync.ToggleVisibility(); } else { Debug.LogWarning("HeadphoneVisibilitySync not yet found."); } } public void ShowMyHeadphones() { if (headphoneSync != null) { headphoneSync.SetVisibility(true); } else { Debug.LogWarning("HeadphoneVisibilitySync not yet found."); } } public void HideMyHeadphones() { if (headphoneSync != null) { headphoneSync.SetVisibility(false); } else { Debug.LogWarning("HeadphoneVisibilitySync not yet found."); } } }