Unity Android split by binary -> no sound


(Mesut Özdogan) #1

The normal unity android build (without split by binary) will work without problems. After spliting the apk and obb (as needed for >100mb apps) the sound will not work. Do I have to change anything?

Thx.


(Nicholas Wilcox) #2

You’ll need to make some changes. The simplest would be to use Unity’s WWW class to read the .bank files from the assets folder within the OBB and write them into the Application.persistentDataPath folder. Then in FMOD_Listener.cs change

bankPath = "file:///android_asset";

to

bankPath = Application.persistenDataPath;

(Mesut Özdogan) #3

Thank you for helping out. We had some other priority bugs to fix :), so sorry for the late response.

Here is our code, free to use (do not forget to change banks ="", see answer above):

        WWW wwwAllBanksTextFile = new WWW( System.IO.Path.Combine( Application.streamingAssetsPath, "FMOD_bank_list.txt" ) );

        yield return wwwAllBanksTextFile;

        if( wwwAllBanksTextFile.error == null )
        {
            string[] banks = wwwAllBanksTextFile.text.Split( '\n' );

            foreach( string bank in banks ) 
            {
                if( bank.Length <= 0 )
                    continue;

                // try to open persistent file:
                WWW wwwBankPersistentFile = new WWW( System.IO.Path.Combine( Application.persistentDataPath, bank ) );

                yield return wwwBankPersistentFile;

                // if not found: not in persistent file space
                if( wwwBankPersistentFile.error != null )
                {
                    // Try to copy it from streaming assets path
                    WWW wwwBankTmp = new WWW( System.IO.Path.Combine( Application.streamingAssetsPath, bank ) );

                    yield return wwwBankTmp;

                    if( wwwBankTmp.error == null )
                    {
                        File.WriteAllBytes( System.IO.Path.Combine( Application.persistentDataPath, bank ), wwwBankTmp.bytes );
                    }
                    else
                    {
                        ErrorText.text += "ERROR 1002: " + bank + " file in streaming storage not found!\n";
                    }
                }
            }
        }
        else
        {
            ErrorText.text += "ERROR 1003: Bank list not found!\n";
        }

(Nicholas Wilcox) #4

1.07.04 will have support for split binary out of the box in both the 2.0 and Legacy integrations.