Created
January 17, 2014 02:34
-
-
Save yuseinishiyama/8467497 to your computer and use it in GitHub Desktop.
For syncing events with audio.
(For Unity3d)
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; | |
[AddComponentMenu("Scripts/BGM/Seeker")] | |
public class Seeker : MonoBehaviour | |
{ | |
public float seekTime { | |
get { | |
return isSeeking ? (float)AudioSettings.dspTime - startTimeByDspTime : 0; | |
} | |
} | |
float startTimeByDspTime; | |
bool isSeeking = false; | |
public void StartSeeking () | |
{ | |
isSeeking = true; | |
startTimeByDspTime = (float)AudioSettings.dspTime; | |
} | |
public void StopSeeking () | |
{ | |
startTimeByDspTime = 0; | |
isSeeking = false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment