好的,所以我把这段代码压缩到一行:
gameObject.GetComponents(AudioSource)[0].audio.Play();
这一行给了我这个错误:
InvalidCastException: Cannot cast from source type to destination type.
scriptexplosion+$Start$4+$.MoveNext () (at Assets/scriptexplosion.js:7)
我的问题是如何将组件数组转换为 AudioSource 数组?