Unity:自動取得Audio播放長度並在播完自動銷毀

views

關鍵字

myAudio.length;

C# Script

將Audio檔直接拖到Project面板後 (設定成 Play on Awake)

然後將此script加在底下後

按下播放後 就會聽到聲音 然後自動根據聲音長度銷毀

 

如果只是AudioClip型態的檔案 要取得其長度 可用下面方式

 

 

This entry was posted in Unity and tagged by Mr.M. Bookmark the permalink.


Leave a Reply

Your email address will not be published. Required fields are marked *