-
-
Save peroon/fcc4169049a7142d4722 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; | |
// 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