====== Playing audio in VCI ====== You can use [[https://docs.unity3d.com/ja/current/Manual/class-AudioClip.html | AudioClip]] in VCI and control it from VCI script (Lua).\\ Here, we will explain the simplest way to use AudioClip. ===== Example audio ===== {{ vci:sample:sample_advanced:clipname.wav |}} The recommended audio format is 44.1kHz 16bit WAVE.\\ There are some audio formats which may be playable on Unity but not playable after being exported as a VCI. ====== Embedding audio files in Unity ====== {{vci:sample:sample_advanced:tutorial_sound.png?600|}} You may attach audio files (.wav, for instance) on any assets in Unity\\ be it a SubItem or a grandchildren object. You can embed multiple audio files. However make sure that there are no two audio files with the same name, as audio files are distinguished by their file names. ===== VCI script ===== By using _ALL_PlayAudioFromName, you can play the embedded audio specified with its **file name**.\\ In this example, we embedded "clipname.wav", so specify "clipname". function onUse() vci.assets._ALL_PlayAudioFromName("clipname") end If you want to play a different audio file depending on the item being used, do as shown below.\\ The argument "item" in onUse(item) contains the name of the SubItem as a string.\\ By comparing the item in if statement, you can play different audio clips depending on its name. function onUse(item) if item == "Cube" then vci.assets._ALL_PlayAudioFromName("clipname") end end