Exemple #1
0
	/// Load a language-specific bank from WWW object
	public void LoadLocalizedBank(string in_bankFilename)
	{
		var bankPath = "file://" + System.IO.Path.Combine(
			               System.IO.Path.Combine(AkBasePathGetter.GetPlatformBasePath(), AkSoundEngine.GetCurrentLanguage()),
			               in_bankFilename);
		DoLoadBank(bankPath);
	}
    /// Load a language-specific bank from WWW object
    public void LoadLocalizedBank(string in_bankFilename)
    {
        var bankPath = "file://" + System.IO.Path.Combine(
            System.IO.Path.Combine(AkUtilities.GetWiseBankFolder_Full(), AkSoundEngine.GetCurrentLanguage()),
            in_bankFilename);

        DoLoadBank(bankPath);
    }
        public DecodableBankHandle(string name, bool save) : base(name)
        {
            saveDecodedBank = save;

            var bankFileName = bankName + ".bnk";

            // test language-specific decoded file path
            var language            = AkSoundEngine.GetCurrentLanguage();
            var decodedBankFullPath = AkSoundEngineController.GetDecodedBankFullPath();

            decodedBankPath = System.IO.Path.Combine(decodedBankFullPath, language);
            var decodedBankFilePath = System.IO.Path.Combine(decodedBankPath, bankFileName);

            var decodedFileExists = System.IO.File.Exists(decodedBankFilePath);

            if (!decodedFileExists)
            {
                // test non-language-specific decoded file path
                decodedBankPath     = decodedBankFullPath;
                decodedBankFilePath = System.IO.Path.Combine(decodedBankPath, bankFileName);
                decodedFileExists   = System.IO.File.Exists(decodedBankFilePath);
            }

            if (decodedFileExists)
            {
                try
                {
                    var decodedFileTime     = System.IO.File.GetLastWriteTime(decodedBankFilePath);
                    var defaultBankPath     = AkBasePathGetter.GetSoundbankBasePath();
                    var encodedBankFilePath = System.IO.Path.Combine(defaultBankPath, bankFileName);
                    var encodedFileTime     = System.IO.File.GetLastWriteTime(encodedBankFilePath);

                    decodeBank = decodedFileTime <= encodedFileTime;
                }
                catch
                {
                    // Assume the decoded bank exists, but is not accessible. Re-decode it anyway, so we do nothing.
                }
            }
        }
        //Todo : support decoding banks and saving decoded banks
        public void LoadBank(WwiseAddressableSoundBank bank, bool decodeBank = false, bool saveDecodedBank = false, bool addToBankDictionary = true)
        {
            bank.decodeBank      = decodeBank;
            bank.saveDecodedBank = saveDecodedBank;
            if (m_AddressableBanks.ContainsKey(bank.name))
            {
                m_AddressableBanks.TryGetValue(bank.name, out bank);
            }
            else if (addToBankDictionary)
            {
                m_AddressableBanks.TryAdd(bank.name, bank);
            }

            if (bank.loadState == BankLoadState.Unloaded || bank.loadState == BankLoadState.WaitingForInitBankToLoad)
            {
                if (!InitBankLoaded && bank.name != "Init")
                {
                    UnityEngine.Debug.Log($"Wwise Addressable Bank Manager: {bank.name} bank will be loaded after the init bank is loaded");
                    bank.loadState = BankLoadState.WaitingForInitBankToLoad;
                    return;
                }
            }
            if (bank.loadState == BankLoadState.Loading)
            {
                bank.refCount += 1;
                return;
            }

            if (bank.loadState == BankLoadState.Loaded)
            {
                bank.refCount += 1;
                return;
            }

            bank.refCount += 1;
            bank.loadState = BankLoadState.Loading;

            if (bank.Data == null)
            {
                UnityEngine.Debug.LogError($"Wwise Addressable Bank Manager : {bank.name} could not be loaded - Bank reference not set");
                m_AddressableBanks.TryRemove(bank.name, out _);
                return;
            }

            AssetReferenceWwiseBankData bankData;

            if (bank.Data.ContainsKey("SFX"))
            {
                UnityEngine.Debug.Log($"Wwise Addressable Bank Manager: Loading {bank.name} bank");
                bankData             = bank.Data["SFX"];
                bank.currentLanguage = "SFX";
            }
            else
            {
                var currentLanguage = AkSoundEngine.GetCurrentLanguage();
                if (bank.Data.ContainsKey(currentLanguage))
                {
                    bankData             = bank.Data[currentLanguage];
                    bank.currentLanguage = currentLanguage;
                    UnityEngine.Debug.Log($"Wwise Addressable Bank Manager: Loading {bank.name} - {currentLanguage}");
                }
                else
                {
                    UnityEngine.Debug.LogError($"Wwise Addressable Bank Manager: {bank.name} could not be loaded in {currentLanguage} language ");
                    m_AddressableBanks.TryRemove(bank.name, out _);
                    return;
                }
            }

            LoadBankAsync(bank, bankData);
        }