Skip to content

Instantly share code, notes, and snippets.

@LordNed
Created March 28, 2015 23:56
Show Gist options
  • Save LordNed/6b0882b3eba009516f3b to your computer and use it in GitHub Desktop.
Save LordNed/6b0882b3eba009516f3b to your computer and use it in GitHub Desktop.
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