Skip to content

Instantly share code, notes, and snippets.

@peroon
Created December 3, 2015 06:58
Show Gist options
  • Save peroon/fcc4169049a7142d4722 to your computer and use it in GitHub Desktop.
Save peroon/fcc4169049a7142d4722 to your computer and use it in GitHub Desktop.
音とアニメーションのシーク
using UnityEngine;
using System.Collections;
// BGMとアニメーションを指定時間にシーク
public class MainSkipAnimation3D : MonoBehaviour {
// 参照
public Animator animator;
// パラメータ
public float timeFromStart = 0.0f;
public float skipTargetTime = 20.0f;
public float bgmWaitTime = 5.0f; // 音の再生を遅らせる
void Start () {
StartCoroutine (StartBGM ());
}
IEnumerator StartBGM(){
yield return new WaitForSeconds (bgmWaitTime);
SoundManager.Instance.PlayBGM (BGM.UNITE_IN_THE_SKY);
yield return null;
}
void Update () {
timeFromStart += Time.deltaTime;
}
public void OnClickSkipButton(){
// Seek BGM
SoundManager.Instance.SeekBGM (skipTargetTime - bgmWaitTime);
// Seek Animation
animator.SetTime (skipTargetTime);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment