MusicArea(LoopTrack[] other) { loops = new LoopTrack[other.Length]; for (int i = 0; i < other.Length; ++i){ loops[i] = new LoopTrack(other[i]); } }
MusicArea(LoopTrack[] other) { loops = new LoopTrack[other.Length]; for (int i = 0; i < other.Length; ++i) { loops[i] = new LoopTrack(other[i]); } }
public void initializeEditorAudio(LoopTrack[] loops) { editorAudio.Clear(); foreach (LoopTrack track in loops){ AudioSource aud = createAudioSource(track, "Editor Audio"); print ("Adding " + track.clip.name); editorAudio.Add(aud); } }
public void AddTrack(LoopTrack aTrack) { PlayingTrack pt = new PlayingTrack(); pt.audioSource = GetNewAudioSource(aTrack); pt.loopTrack = aTrack; playingTracks.Add(pt); }
public static void CreateMusicArea(GameObject obj, LoopTrack[] other) { MusicArea ma = obj.AddComponent<MusicArea>(); ma.loops = new LoopTrack[other.Length]; obj.name = "Music Area " + number++; for (int i = 0; i < other.Length; ++i){ ma.loops[i] = new LoopTrack(other[i]); } }
public void StopTrack(LoopTrack aTrack) { PlayingTrack pt = playingTracks.Find(x => x.loopTrack == aTrack); if (pt == null) { Debug.LogError("Trying to stop track that hasn't been added: " + aTrack.ToString()); return; } pt.targetVolume = 0; }
public void SetBaseTrack(LoopTrack aTrack) { PlayingTrack pt = playingTracks.Find(x => x.loopTrack == aTrack); if (pt == null) { Debug.LogError("Trying to set base track that hasn't been added: " + aTrack.ToString()); return; } baseTrack = pt; }
void OnLoopStopped(LoopTrack aTrack) { if (currentTracksToRemove.Exists(x => x == aTrack)) { currentTracksToRemove.Remove(aTrack); musicLooper.RemoveTrack(aTrack); if (currentTracksToRemove.Count == 0) { PlaySequenceTracks(); musicLooper.onLoopStopped -= OnLoopStopped; } } }
void OnLoopStopped(LoopTrack aTrack) { if (currentChange != null && aTrack == currentChange.track) { currentChange = null; } if (currentTransition.state == Transition.State.StoppingPrevious) { if (currentTransition.tracksToRemove.Exists(x => x == aTrack)) { currentTransition.state = Transition.State.WaitToStartNextLoops; } } }
AudioSource createAudioSource(LoopTrack track, string name) { GameObject go = new GameObject(); go.transform.parent = transform; go.AddComponent <AudioSource>(); go.transform.position = transform.position; go.transform.rotation = Quaternion.Euler(0, 0, 0); go.name = name; AudioSource aud = go.GetComponent <AudioSource>(); aud.loop = true; aud.clip = track.clip; aud.volume = track.volume; return(aud); }
void OnLoopStarted(LoopTrack aTrack) { if (currentChange != null && aTrack == currentChange.track) { currentChange = null; } if (currentTransition.state == Transition.State.StartingTransitionTracks) { StopTracksToRemove(); } else if (currentTransition.state == Transition.State.StartingNextLoops && currentTransition.nextCollection.loopBase == aTrack) { CompleteTransition(); } }
public void RemoveTrack(LoopTrack aTrack) { PlayingTrack pt = playingTracks.Find(x => x.loopTrack == aTrack); if (pt == null) { Debug.LogError("Trying to remove track that hasn't been added: " + aTrack.ToString()); return; } if (pt == baseTrack) { Debug.LogError("Trying to remove base track [" + aTrack.ToString() + "], replace with another track first!"); return; } Destroy(pt.audioSource); playingTracks.Remove(pt); }
AudioSource GetNewAudioSource(LoopTrack aLoopTrack) { AudioSource audioSource = gameObject.AddComponent <AudioSource>(); audioSource.clip = aLoopTrack.clip; audioSource.volume = 0; audioSource.loop = true; audioSource.outputAudioMixerGroup = mixer; audioSource.Play(); float time = 0; if (baseTrack != null) { time = baseTrack.audioSource.time % aLoopTrack.clip.length; } audioSource.time = time; return(audioSource); }
AudioSource createAudioSource(LoopTrack track, string name) { GameObject go = new GameObject(); go.transform.parent = transform; go.AddComponent<AudioSource>(); go.transform.position = transform.position; go.transform.rotation = Quaternion.Euler(0,0,0); go.name = name; AudioSource aud = go.GetComponent<AudioSource>(); aud.loop = true; aud.clip = track.clip; aud.volume = track.volume; return aud; }
public PlayingTrack GetPlayingTrackIfActive(LoopTrack aTrack) { return(playingTracks.Find(x => x.loopTrack == aTrack)); }
public Track(LoopTrack aLoopTrack) { loopTrack = aLoopTrack; }
public LoopTrack(LoopTrack other) { clip = other.clip; volume = other.volume; }
AudioSource createAudioSource(LoopTrack track) { return createAudioSource(track, "Audio Track"); }
public void playAllLoops(LoopTrack[] loops) { if (inGameplay) return; transform.position = follow.transform.position; if (editorAudio.Count != 0) return; initializeEditorAudio(loops); foreach(AudioSource aud in editorAudio){ if (aud) aud.Play(); } }
void AddTrack(LoopTrack aTrack) { musicLooper.AddTrack(aTrack); }
void AddTrackChange(LoopTrack aTrack, bool aShouldPlay) { AddTrackChange(new LoopChange(aTrack, aShouldPlay)); }
void RemoveTrack(LoopTrack aTrack) { musicLooper.RemoveTrack(aTrack); }
public LoopChange(LoopTrack aTrack, bool aStart) { track = aTrack; play = aStart; }
AudioSource createAudioSource(LoopTrack track) { return(createAudioSource(track, "Audio Track")); }
// Public Function //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // setTracks is called by a MusicArea when the music area is activated // calling set tracks queues the new tracks to be added in the next time loopbase reaches its end public void setTracks(LoopTrack[] area) { for (int i = 0; i < area.Length; ++i){ waitingLayers[i] = createAudioSource(area[i], "AudioTrack from Set"); } }