Skip to content

Instantly share code, notes, and snippets.

@TheStoneBook
Last active June 25, 2018 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheStoneBook/4ca41da17eff3c1bcf46aaf027877890 to your computer and use it in GitHub Desktop.
Save TheStoneBook/4ca41da17eff3c1bcf46aaf027877890 to your computer and use it in GitHub Desktop.
【Unity】SEの終了を知らせるコールバック
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EndSECallBack : MonoBehaviour {
private AudioSource SE;
void Start () {
SE = GetComponent<AudioSource> ();
}
void Update () {
if (Input.GetKeyDown (KeyCode.A))
{
SE.Play ();
StartCoroutine (CheckSEPlaying (() => {
Debug.Log("終わったよー");
}));
}
}
public delegate void EndSE();
private IEnumerator CheckSEPlaying (EndSE callback) {
while (true) {
yield return new WaitForFixedUpdate ();
if (!SE.isPlaying) {
callback ();
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment