예제 #1
0
        /// <summary>
        /// Searches for the specified sound with a matching name.
        /// </summary>
        /// <returns>
        /// A reference to a sound, if found. Null reference otherwise.
        /// </returns>
        /// <remarks>
        /// <para>If multiple banks have sounds with a matching name, primary sound bank will be checked first.
        /// Within a bank, the first occurrence of found sound will be used.</para>
        /// </remarks>
        public static Sound GetSound(string name)
        {
            if (shutdown)
            {
                return(null);
            }

            // Check primary bank first
            SoundBank primaryBank = bankManager.PrimaryBank;

            if (primaryBank != null && primaryBank.ContainsAsset(name))
            {
                return(primaryBank.GetSound(name));
            }

            // Check other banks
            for (int i = 0; i < bankManager.Banks.Count; i++)
            {
                SoundBank bank = bankManager.Banks[i];

                // Skip primary bank
                if (bank == primaryBank)
                {
                    continue;
                }

                if (bank.ContainsAsset(name))
                {
                    return(bank.GetSound(name));
                }
            }

            return(null);
        }
예제 #2
0
        /// <summary>
        /// Registers new sound bank.
        /// </summary>
        /// <param name="bank">A reference to a sound bank to register.</param>
        /// <returns>
        /// True, if sound bank was succesfully registered. False otherwise.
        /// </returns>
        public static bool RegisterBank(SoundBank bank)
        {
            if (shutdown)
            {
                return(false);
            }

            return(bankManager.RegisterBank(bank));
        }
예제 #3
0
        internal void Update(SoundBank bank)
        {
            for (int i = usedSounds.Count - 1; i >= 0; i--)
            {
                SoundInstance instance = usedSounds[i];
                instance.Update();

                if (!instance.Paused && !instance.Playing)
                {
                    ReleaseSound(i);
                }
            }
        }
예제 #4
0
 internal SoundBus(SoundBank bank_, string name_)
 {
     bank = bank_;
     name = name_;
 }
예제 #5
0
 public void OnEnable()
 {
     bank = target as SoundBank;
 }