Пример #1
0
        // Load all Audio File's into the SoundFile dictionary
        public void LoadSoundMetaFiles(Action completion)
        {
            // Make sure all 'audio files on disk' have meta files
            SoundFile.CreateNewMetas();

            // Populate the SoundFile dictionary
            int numLoaded = 0;
            Dictionary <string, SoundFile> sfDict = this.soundDictionary;

            foreach (var filename in SoundFile.metaFiles)
            {
                SoundFile newSoundFile = SoundFile.ReadFromMeta(filename);

                // If the SoundFile has already been loaded, don't reload it
                if (sfDict.TryGetValue(newSoundFile.filename, out SoundFile sf))
                {
                    if (sf.loadState == LoadState.Success)
                    {
                        ++numLoaded;
                    }
                    continue;
                }

                newSoundFile.loadState        = LoadState.NotLoaded;
                sfDict[newSoundFile.filename] = newSoundFile;
            }

            layoutManagerDelegate?.LayoutManagerLoadedAudioClipsChanged(this,
                                                                        hotspotCount: layout != null ? layout.hotspots.Count : 0);
            // Debug.Log("Reloaded Metafiles... " + numLoaded + " SoundClip(s) are loaded. "
            //                            + ( SoundFile.metaFiles.Count() - numLoaded ) + " NOT loaded.");
            completion();
        }
Пример #2
0
        public void LoadSoundFiles(Action completion)
        {
            var into = this.soundDictionary; // A nice little alias for it

            // Make sure we have data for every wav
            SoundFile.CreateNewMetas();

            // load all sound files from their metas
            foreach (var filename in SoundFile.metaFiles)
            {
                SoundFile sf      = SoundFile.ReadFromMeta(filename);
                string    wavName = sf.filename;

                // If the SoundFile has already been loaded, don't reload it
                if (soundDictionary.ContainsKey(wavName))
                {
                    continue;
                }

                layoutManagerDelegate?.StartCoroutineOn(SoundFile.LoadSoundFileFromMeta(filename, into));
            }
            layoutManagerDelegate?.StartCoroutineOn(SoundFile.AwaitLoading(into, completion));
        }