Created
March 28, 2015 23:56
-
-
Save LordNed/6b0882b3eba009516f3b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
[RequireComponent(typeof(AudioSource))] | |
public class DawnAudioNotification : MonoBehaviour | |
{ | |
private AudioSource m_audioClip; | |
private void Awake() | |
{ | |
m_audioClip = GetComponent<AudioSource>(); | |
} | |
private void OnEnable() | |
{ | |
Pigeons.Subscribe<Messages.OnDayNightChange>(OnDayNightStateChange); | |
} | |
private void OnDisable() | |
{ | |
Pigeons.Unsubscribe<Messages.OnDayNightChange>(OnDayNightStateChange); | |
} | |
private void OnDayNightStateChange(Messages.OnDayNightChange message) | |
{ | |
if(message.State == DayNightTimeState.Dawn) | |
m_audioClip.Play(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment