// Update is called once per frame void Update() { if (TopPanel != null) { if (myPanel == null) { myPanel = TopPanel.GetComponent <LobbyTopPanel> (); } if (myPanel != null) { if (myPanel.isInGame && mAudio.isPlaying) { mAudio.Stop(); } else if (!myPanel.isInGame && !mAudio.isPlaying) { mAudio.Play(); } } } }