Exemple #1
0
        /// <summary>
        /// Plays the SoundConnection right then, regardless of what you put at the level parameter of the SoundConnection.
        /// </summary>
        /// <param name='sc'>
        /// The SoundConnection.
        /// </param>
        /// <param name='syncPlaybackTime'>
        /// Whether the playback times should be synced.
        /// </param>
        /// <param name='trackNumber'>
        /// Track number to skip to, starting at 0.
        /// </param>
        public static void PlayConnection(SoundConnection sc, bool syncPlaybackTime = false, int trackNumber = 0)
        {
            int         currentTimeSamples = 0;
            AudioSource currentSource      = null;

            if (syncPlaybackTime)
            {
                currentSource = GetCurrentAudioSource();
                if (currentSource != null)
                {
                    currentTimeSamples = currentSource.timeSamples;
                }
            }

            for (int i = 0; i < trackNumber; i++)
            {
                Next();
            }
            Ins._PlayConnection(sc);

            if (syncPlaybackTime)
            {
                currentSource = GetCurrentAudioSource();
                if (currentTimeSamples > currentSource.clip.samples)
                {
                    Debug.LogWarning("Your clips are not of equal length. SyncPlayback has restarted the new track");
                    currentTimeSamples = 0;
                }
                currentSource.timeSamples = currentTimeSamples;
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates a SoundConnection.  You can use a scene name or a custom name.  This overload is used for PlayMethods that use Random Delay In Range.
        /// </summary>
        /// <returns>
        /// The SoundConnection.
        /// </returns>
        /// <param name='lvl'>
        /// The level name of the SoundConnection.
        /// </param>
        /// <param name='method'>
        /// The PlayMethod.
        /// </param>
        /// <param name='minDelayPlay'>
        /// The minimum delay.
        /// </param>
        /// <param name='maxDelayPlay'>
        /// The maximum delay.
        /// </param>
        /// <param name='audioList'>
        /// Audio list.
        /// </param>
        public static SoundConnection CreateSoundConnection(string lvl, SoundManager.PlayMethod method, float minDelayPlay, float maxDelayPlay, params AudioClip[] audioList)
        {
            SoundConnection sc = new SoundConnection(lvl, method, minDelayPlay, maxDelayPlay, audioList);

            if (!Application.CanStreamedLevelBeLoaded(lvl))
            {
                sc.SetToCustom();
            }
            return(sc);
        }
Exemple #3
0
        /// <summary>
        /// Creates a SoundConnection.  You can use a scene name or a custom name.  Will default to ContinousPlayThrough.
        /// </summary>
        /// <returns>
        /// The SoundConnection.
        /// </returns>
        /// <param name='lvl'>
        /// The level name of the SoundConnection.
        /// </param>
        /// <param name='audioList'>
        /// Audio list.
        /// </param>
        public static SoundConnection CreateSoundConnection(string lvl, params AudioClip[] audioList)
        {
            SoundConnection sc = new SoundConnection(lvl, SoundManager.PlayMethod.ContinuousPlayThrough, audioList);

            if (!Application.CanStreamedLevelBeLoaded(lvl))
            {
                sc.SetToCustom();
            }
            return(sc);
        }
Exemple #4
0
        /// <summary>
        /// Replaces the SoundConnection at that level.  If a SoundConnection doesn't exist, it will just add it.
        /// </summary>
        /// <param name='sc'>
        /// The SoundConnection.
        /// </param>
        public static void ReplaceSoundConnection(SoundConnection sc)
        {
            int _indexOf = SoundConnectionsContainsThisLevel(sc.level);

            if (_indexOf != SOUNDMANAGER_FALSE)
            {
                RemoveSoundConnectionForLevel(sc.level);
            }
            AddSoundConnection(sc);
        }
Exemple #5
0
        /// <summary>
        /// Adds the SoundConnection to the manager.  It will not add multiple SoundConnections to one level.
        /// </summary>
        /// <param name='sc'>
        /// The SoundConnection.
        /// </param>
        public static void AddSoundConnection(SoundConnection sc)
        {
            int _indexOf = SoundConnectionsContainsThisLevel(sc.level);

            if (_indexOf == SOUNDMANAGER_FALSE)
            {
                if (!Application.CanStreamedLevelBeLoaded(sc.level))
                {
                    sc.isCustomLevel = true;
                }
                Ins.soundConnections.Add(sc);
            }
            else
            {
                Debug.LogWarning("A SoundConnection for this level already exists.  Remove it first.");
            }
        }
Exemple #6
0
 /// <summary>
 /// Sets the current SoundConnection
 /// </summary>
 /// <param name='connection'>
 /// SoundConnection.
 /// </param>
 public static void SetCurrentSoundConnection(SoundConnection connection)
 {
     Ins.currentSoundConnection = connection;
 }