public void ReloadSamples() { for (int i = 0; i < samples.Count; i++) { SerializedSample serializedSample = samples[i]; serializedSample.CheckClipFileChange(); } }
public static SerializedSample GetSample(string name) { SerializedSample serializedSample = null; if (level != null) { serializedSample = level.library.GetSample(name); } if (serializedSample == null && main != null) { serializedSample = main.library.GetSample(name); } return(serializedSample); }
public void MarkAllMissing() { for (int i = 0; i < samples.Count; i++) { SerializedSample serializedSample = samples[i]; for (int j = 0; j < serializedSample.clips.Count; j++) { if (!serializedSample.clips[j].isEmbedded) { serializedSample.clips[j].missingFile = true; } } } }
public void AddSample(SerializedSample sample) { map[sample.name] = sample; samples.Add(sample); sample.library = this; if (!categoryMap.TryGetValue(sample.category, out SampleCategory value)) { SampleCategory sampleCategory = new SampleCategory(); sampleCategory.name = sample.category; value = sampleCategory; categoryMap[sample.category] = value; categories.Add(value); } value.samples.Add(sample); }
public void LoadJson(SerializedSampleLibrary savedLibrary) { for (int i = 0; i < savedLibrary.samples.Count; i++) { SerializedSample serializedSample = savedLibrary.samples[i]; SerializedSample serializedSample2 = library.GetSample(serializedSample.name); if (serializedSample2 == null) { SerializedSample serializedSample3 = new SerializedSample(); serializedSample3.category = serializedSample.category; serializedSample3.name = serializedSample.name; serializedSample2 = serializedSample3; library.AddSample(serializedSample2); } serializedSample2.Merge(serializedSample); } }
public void SetChild(string localId, IClip container) { switch (SerializedSample.GetChildType(localId)) { case SampleContainerChildType.Start: start = container; break; case SampleContainerChildType.Stop: stop = container; break; default: loop = container; break; } }
public void Merge(SerializedSample serialized) { if (category != serialized.category) { Debug.Log("Category change not supported"); } isSwitch = serialized.isSwitch; isLoop = serialized.isLoop; crossFade = serialized.crossFade; vB = serialized.vB; vR = serialized.vR; pB = serialized.pB; pR = serialized.pR; for (int i = 0; i < serialized.clips.Count; i++) { AddClip(serialized.clips[i].filename, serialized.clips[i].id, serialized.clips[i]); } }
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 { } }
public void RemoveMissing() { map.Clear(); Dictionary <string, SampleCategory> dictionary = categoryMap; categoryMap = new Dictionary <string, SampleCategory>(); categories.Clear(); for (int num = samples.Count - 1; num >= 0; num--) { SerializedSample serializedSample = samples[num]; serializedSample.RemoveMissingCips(); if (serializedSample.clips.Count == 0) { samples.RemoveAt(num); } else { map[serializedSample.name] = serializedSample; if (!categoryMap.TryGetValue(serializedSample.category, out SampleCategory value)) { if (dictionary.TryGetValue(serializedSample.category, out value)) { value.samples.Clear(); } else { SampleCategory sampleCategory = new SampleCategory(); sampleCategory.name = serializedSample.category; value = sampleCategory; } categoryMap[serializedSample.category] = value; categories.Add(value); } value.samples.Add(serializedSample); } } }