public void Merge(SerializedClip serialized) { clip = serialized.clip; fileTimestamp = serialized.fileTimestamp; vB = serialized.vB; vR = serialized.vR; pB = serialized.pB; pR = serialized.pR; }
public SerializedClip AddClip(string path, string id, SerializedClip copyFrom = null, AudioClip loadedClip = null) { if (containers == null) { containers = new Dictionary <string, IClipContainer>(); } if (clips == null) { clips = new List <SerializedClip>(); } SerializedClip serializedClip = null; for (int i = 0; i < clips.Count; i++) { if (clips[i].id == id) { serializedClip = clips[i]; break; } } if (serializedClip == null) { SerializedClip serializedClip2 = new SerializedClip(); serializedClip2.id = id; serializedClip2.filename = path; serializedClip = serializedClip2; clips.Add(serializedClip); } serializedClip.filename = path; if (loadedClip != null) { serializedClip.clip = loadedClip; serializedClip.isEmbedded = true; serializedClip.clipDirty = false; serializedClip.missingFile = false; } if (copyFrom != null) { serializedClip.Merge(copyFrom); } serializedClip.sample = this; serializedClip.CheckClipFileChange(); IClipContainer clipContainer = EnsureContainerFor(id); if (clipContainer != null) { ParseId(id, out string _, out string localId); clipContainer.SetChild(localId, serializedClip); } else { root = serializedClip; } return(serializedClip); }
public SerializedClip GetClip(SerializedClip currentClip, char choice, SampleContainerChildType loopType) { if (root == null) { return(null); } if (root is SerializedClip) { return(root as SerializedClip); } return((root as IClipContainer).GetClip(currentClip?.id, choice, loopType)); }
public IEnumerator LoadClips() { terminateLoading = true; while (loading > 0) { yield return(null); } terminateLoading = false; loading++; if (builtIn) { while (SoundSourcePool.instance == null && !terminateLoading) { yield return(null); } } else { for (int i = 0; i < clips.Count; i++) { if (terminateLoading) { break; } SerializedClip clip = clips[i]; if (clip.clip == null || clip.clipDirty) { DateTime timestamp = File.GetLastWriteTimeUtc(Path.Combine(library.library.wavPath, clip.filename)); WWW www = new WWW("file://" + Path.GetFullPath(Path.Combine(library.library.wavPath, clip.filename))); while (!www.isDone) { yield return(null); } clip.LoadClip(www.GetAudioClip(threeD: true, stream: false), timestamp); } } } loading--; if (!terminateLoading) { loaded = true; if (this.onLoaded != null) { this.onLoaded(); } } }
public void CheckClipFileChange() { bool flag = false; for (int i = 0; i < clips.Count; i++) { SerializedClip serializedClip = clips[i]; serializedClip.CheckClipFileChange(); if (serializedClip.clipDirty) { flag = true; break; } } if (flag) { Coroutines.StartGlobalCoroutine(LoadClips()); } }
public void LoadFilesystem() { library.MarkAllMissing(); string fullPath = Path.GetFullPath(wavPath); try { string[] directories = Directory.GetDirectories(fullPath); for (int i = 0; i < directories.Length; i++) { string[] files = Directory.GetFiles(directories[i], "*.wav"); for (int j = 0; j < files.Length; j++) { ParseSamplePath(files[j], out string category, out string name, out string id); if (!name.StartsWith("._")) { SerializedSample serializedSample = library.GetSample(name); if (serializedSample == null) { SerializedSample serializedSample2 = new SerializedSample(); serializedSample2.category = category; serializedSample2.name = name; serializedSample = serializedSample2; library.AddSample(serializedSample); } serializedSample.category = category; SerializedClip serializedClip = serializedSample.AddClip(GetRelativePathTo(fullPath, files[j]), id); serializedClip.missingFile = false; } } } library.RemoveMissing(); library.ReloadSamples(); SoundManager.main.ReapplySamples(); SoundManager.level.ReapplySamples(); } catch { } }