campfire/Assets/Scripts/SelfDestructAfterPlaying.cs

17 lines
348 B
C#
Raw Normal View History

2020-04-20 20:46:48 +02:00
using UnityEngine;
[RequireComponent(typeof(AudioSource))]
public class SelfDestructAfterPlaying : MonoBehaviour {
private AudioSource Source;
private void Awake() {
Source = GetComponent<AudioSource>();
}
private void LateUpdate() {
if (!Source.isPlaying) {
Destroy(gameObject);
}
}
}