Last active
June 25, 2018 14:35
-
-
Save TheStoneBook/4ca41da17eff3c1bcf46aaf027877890 to your computer and use it in GitHub Desktop.
【Unity】SEの終了を知らせるコールバック
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 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