![]() ![]() There are just many reasons why Audio many not play in Unity. I can't get it to play the sound it sees the audio source but my If 2D game, use OnCollisionEnter2D instead. Use collision detection + collider instead of the Update function to detect the hit then play audio: void OnCollisionEnter(Collision collision) Different settings might be used, but I haven't test them.I am trying to program a script that when you hit an enemy it plays a The audio i'm using have the following settings. Make sure to clear cache or change version code before testing the new object. ![]() Simply load the object and after that Unload the asset bundle using assetBundle.Unload(false). No special implementations are required on the Asset Bundle downloading code. After that it won't be able to retrive proprieties from the audio clip. Please make sure to store all information about the audio clip on the Coroutine created on the script. You can always call the PlayAudio method from other sources. To test if the audio plays correctly you can simply tap on the debug boolean on inspector. You can attach the script below on an object stored in an Asset Bundle. Both without error and with the audio being played as expected. It has been tested on Unity editor 5.6.03f and on my iPhone 6, iOS 10 and Xcode 8.3. Here you can use the following code snipped attached on an asset bundle. After that It is possible to call _audioSource.Play() whenever you want while the Object is on scene, even if the Asset Bundle has been unloaded (of course with false parameter, as the objects shouldn't be destroyed). Right now I can play the audio whenever I want using by add the audio on a Audio Play on Awake, Play and Stop it instantly. When you attempt to play an Audio after the asset bundle has been unloaded, it fails an the "Error: Cannot create FMOD::Sound instance". Of course the ideal option is to be able to play an audio whenever we want. On my first tests the clip plays correctly when the audio is loaded on the Audio Source component and played on Awake method. ![]() I found a quite dirty turnaround solution.Īs pointed out before the error occurs when you try to Play an audio clip after the asset bundle has been unloaded. If possible feel free to open a private line of communication with me, I may be able to give more details in that case. ![]() running two copies now, one to try and debug this in 5.5 and one in case I need to update any fixes in 5.3.5p5). I realise this isn't the greatest help to your developers but I would appreciate any help you can give, this needs to be fixed in order to maintain and update our app (I'm stuck on 5.3.5p5 at the moment, I had to roll back to get it to work a while ago, perhaps that caused corruption. I have tried reimporting all assets and reinstalling Unity on several occasions to no avail. I have however tried to create a test project and it's working as it should, so I wonder if my project has become corrupted or perhaps the complexity of the scene setups have caused an issue. I can then return to the main menu of the app (not part of a bundle) and reload the same bundle again and the same thing happens, with it working on the first scene. The sounds work consistently the first time I load a scene in the bundle, and then when I load another scene in the same bundle, the sound throws:Įrror: Cannot create FMOD::Sound instance for resource archive:/BuildPlayer-SCENENAME/BuildPlayer-SCENENAME.resource, (File not found. I'm now running the same app on iOS & Android and having the same issue in the editor as well when loading those bundles. The issue regarding iOS10 32bit specifically seems to be resolved, mine is something new but related. Unfortunately I can't attach the project due to an NDA. ![]()
0 Comments
Leave a Reply. |