GetDecodedBankFullPath() public static method

public static GetDecodedBankFullPath ( ) : string
return string
Beispiel #1
0
    public AkBankHandle(string name, bool decode, bool save)
    {
        bankName        = name;
        bankCallback    = null;
        decodeBank      = decode;
        saveDecodedBank = save;

        // Verify if the bank has already been decoded
        if (decodeBank)
        {
            string DecodedBankPath = System.IO.Path.Combine(AkInitializer.GetDecodedBankFullPath(), bankName + ".bnk");
            string EncodedBankPath = System.IO.Path.Combine(AkBasePathGetter.GetValidBasePath(), bankName + ".bnk");
            if (System.IO.File.Exists(DecodedBankPath))
            {
                try
                {
                    if (System.IO.File.GetLastWriteTime(DecodedBankPath) > System.IO.File.GetLastWriteTime(EncodedBankPath))
                    {
                        relativeBasePath = AkInitializer.GetDecodedBankFolder();
                        decodeBank       = false;
                    }
                }
                catch
                {
                    // Assume the decoded bank exists, but is not accessible. Re-decode it anyway, so we do nothing.
                }
            }
        }
    }
Beispiel #2
0
    public AkBankHandle(string name, bool decode, bool save)
    {
        bankName        = name;
        bankCallback    = null;
        decodeBank      = decode;
        saveDecodedBank = save;

#if !UNITY_EDITOR
        // Verify if the bank has already been decoded
        if (decodeBank)
        {
            if (System.IO.File.Exists(System.IO.Path.Combine(AkInitializer.GetDecodedBankFullPath(), bankName + ".bnk")))
            {
                relativeBasePath = AkInitializer.GetDecodedBankFolder();
                decodeBank       = false;
            }
        }
#endif
    }
Beispiel #3
0
    public override void OnChildInspectorGUI()
    {
        serializedObject.Update();

        m_LoadBankEventHandlerInspector.OnGUI();
        m_UnloadBankEventHandlerInspector.OnGUI();

        GUILayout.Space(5);

        GUILayout.BeginVertical("Box");
        {
            bool oldDecodeValue      = decode.boolValue;
            bool oldSaveDecodedValue = saveDecoded.boolValue;
            EditorGUILayout.PropertyField(loadAsync, new GUIContent("Asynchronous:"));
            EditorGUILayout.PropertyField(decode, new GUIContent("Decode compressed data:"));

            if (decode.boolValue)
            {
                if (decode.boolValue != oldDecodeValue && AkWwiseProjectInfo.GetData().preparePoolSize == 0)
                {
                    EditorUtility.DisplayDialog("Warning", "You will need to define a prepare pool size in the AkInitializer component options.", "Ok");
                }
                EditorGUILayout.PropertyField(saveDecoded, new GUIContent("Save decoded bank:"));
                if (oldSaveDecodedValue == true && saveDecoded.boolValue == false)
                {
                    string decodedBankPath = System.IO.Path.Combine(AkInitializer.GetDecodedBankFullPath(), bankName.stringValue + ".bnk");
                    try
                    {
                        System.IO.File.Delete(decodedBankPath);
                    }
                    catch (Exception e)
                    {
                        Debug.Log("WwiseUnity: Could not delete existing decoded SoundBank. Please delete it manually. " + e.ToString());
                    }
                }
            }
        }
        GUILayout.EndVertical();

        serializedObject.ApplyModifiedProperties();
    }
Beispiel #4
0
        public DecodableBankHandle(string name, bool save) : base(name)
        {
            saveDecodedBank = save;

            var bankFileName = bankName + ".bnk";

            // test language-specific decoded file path
            var language = AkInitializer.GetCurrentLanguage();

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

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

            if (!decodedFileExists)
            {
                // test non-language-specific decoded file path
                decodedBankPath     = AkInitializer.GetDecodedBankFullPath();
                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.
                }
            }
        }
Beispiel #5
0
    /// Loads a bank.  This version blocks until the bank is loaded.  See AK::SoundEngine::LoadBank for more information
    public void LoadBank()
    {
        if (m_RefCount == 0)
        {
            AKRESULT res = AKRESULT.AK_Fail;

            // There might be a case where we were asked to unload the SoundBank, but then asked immediately after to load that bank.
            // If that happens, there will be a short amount of time where the ref count will be 0, but the bank will still be in memory.
            // In that case, we do not want to unload the bank, so we have to remove it from the list of pending bank unloads.
            if (AkBankManager.BanksToUnload.Contains(this))
            {
                AkBankManager.BanksToUnload.Remove(this);
                IncRef();
                return;
            }

#if UNITY_EDITOR
            res = AkSoundEngine.LoadBank(bankName, AkSoundEngine.AK_DEFAULT_POOL_ID, out m_BankID);
#else
            if (decodeBank == false)
            {
                string basePathToSet = null;

                if (!string.IsNullOrEmpty(relativeBasePath))
                {
                    basePathToSet = AkBasePathGetter.GetValidBasePath();
                    if (string.IsNullOrEmpty(basePathToSet))
                    {
                        Debug.LogWarning("WwiseUnity: Bank " + bankName + " failed to load (could not obtain base path to set).");
                        return;
                    }

                    res = AkSoundEngine.SetBasePath(System.IO.Path.Combine(basePathToSet, relativeBasePath));
                }
                else
                {
                    res = AKRESULT.AK_Success;
                }

                if (res == AKRESULT.AK_Success)
                {
                    res = AkSoundEngine.LoadBank(bankName, AkSoundEngine.AK_DEFAULT_POOL_ID, out m_BankID);

                    if (!string.IsNullOrEmpty(basePathToSet))
                    {
                        AkSoundEngine.SetBasePath(basePathToSet);
                    }
                }
            }
            else
            {
                if (saveDecodedBank == true)
                {
                    if (!System.IO.Directory.Exists(AkInitializer.GetDecodedBankFullPath()))
                    {
                        try
                        {
                            System.IO.Directory.CreateDirectory(AkInitializer.GetDecodedBankFullPath());
                            System.IO.Directory.CreateDirectory(System.IO.Path.Combine(AkInitializer.GetDecodedBankFullPath(), AkInitializer.GetCurrentLanguage()));
                        }
                        catch
                        {
                            Debug.LogWarning("Could not create decoded SoundBank directory, decoded SoundBank will not be saved.");
                            saveDecodedBank = false;
                        }
                    }
                }
                res = AkSoundEngine.LoadAndDecodeBank(bankName, saveDecodedBank, out m_BankID);
            }
#endif
            if (res != AKRESULT.AK_Success)
            {
                Debug.LogWarning("WwiseUnity: Bank " + bankName + " failed to load (" + res.ToString() + ")");
            }
        }
        IncRef();
    }