Exemplo n.º 1
0
        // Internal - Used by AudioBankMounter
        // Decrements the reference count on the bank named bankName
        // If it hits zero, unloads it
        public void UnloadEventBank(string bankName)
        {
            if (BankReferenceCounts.ContainsKey(bankName))
            {
                BankReferenceCounts[bankName] -= 1;
                if (BankReferenceCounts[bankName] <= 0)
                {
                    BankReferenceCounts.Remove(bankName);

                    Debug.Log("AudioManager: Unload bank " + bankName);

                    var keysToDelete = new List <string>();
                    foreach (var kvp in AudioEvents)
                    {
                        kvp.Value.RemoveAll(e => e.BankName == bankName);
                        if (kvp.Value.Count == 0)
                        {
                            keysToDelete.Add(kvp.Key);
                        }
                    }

                    foreach (var k in keysToDelete)
                    {
                        AudioEvents.Remove(k);
                    }
                }
            }
        }
Exemplo n.º 2
0
        // Internal - Used by AudioBankMounter
        // If bankName is not loaded, loads it and sets the ref count to one
        // Otherwise it just increments the ref count
        public void LoadEventBank(string bankName)
        {
            if (BankReferenceCounts.ContainsKey(bankName))
            {
                BankReferenceCounts[bankName] += 1;
                return;
            }

            BankReferenceCounts[bankName] = 1;

            var bank = Resources.Load(bankName, typeof(AudioEventBank)) as AudioEventBank;

            if (bank == null)
            {
                Debug.Log("Failed to load audio bank " + bankName);
                return;
            }

            if (LogBankLoads)
            {
                Debug.Log("Loading bank " + bankName);
            }


            foreach (var se in bank.AudioEvents)
            {
                if (!AudioEvents.ContainsKey(se.EventName))
                {
                    AudioEvents[se.EventName] = new List <AudioEvent>();
                }
                se.BankName = bankName;
                AudioEvents[se.EventName].Add(se);
            }
        }