Hi,
I’m trying to load a bank from my server, but can’t make it to work on mobile, only desktop.
The original path for Master.bank and Master.Strings.bank is Assets/StreamingAssets/.
I setup integration as Single Platform Build - Import Type: Streaming Assets.
I tried Asset Bundle, but the path will never be the correct one.
When I add Application.persistentDataPath to the bank path, the full real path becomes Assets/StreamingAssets/ + Application.persistentDataPath.
So I’m never able to load from persistentDataPath.
Is there a workaround or something I’m missing?
Here’s the code:
UnityWebRequest MyRequest;
IEnumerator DownloadMusic01()
{
MyRequest = new UnityWebRequest("https://myserver.com/music1.bank", UnityWebRequest.kHttpVerbGET);
path = Path.Combine(System.IO.Path.Combine(Application.streamingAssetsPath), "music1.bank");
MyRequest.downloadHandler = new DownloadHandlerFile(path);
yield return MyRequest.SendWebRequest();
if (MyRequest.isHttpError)
Debug.LogError(MyRequest.error);
else
Debug.Log("File successfully downloaded and saved to " + path);
if (MyRequest.downloadHandler.isDone)
{
bankPathMusic1 = path;
FMOD.Studio.System bankload;
FMOD.Studio.System.create(out bankload);
var loadingResult = bankload.loadBankFile("music1.bank", FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out loadedBank);
loadedBank.loadSampleData();
bankPathMusic1 = "music1.bank";
FMODUnity.RuntimeManager.LoadBank(bankPathMusic1, true);
PlayerStateEvent = "event:/Mix1";
playerState = FMODUnity.RuntimeManager.CreateInstance(PlayerStateEvent);
playerState.start();
}
}