/// <summary> /// Plays the sound. If the parameters are dirty, synthesises sound as it plays, caching it for later. // If they're not, plays from the cached sound. Won't play if caching asynchronously. /// </summary> public void Play() { if (_cachingAsync) { return; } Stop(); if (_params.paramsDirty || _cachingNormal || _cachedWave == null) { // Needs to cache new data _cachedWavePos = 0; _cachingNormal = true; _waveData = null; Reset(true); _cachedWave = new float[_envelopeFullLength]; } else { // Play from cached data _waveData = _cachedWave; _waveDataPos = 0; } _audioPlayer = AudioPlayerFactory.Create(this); _audioPlayer.Play(); }
public static PropertyGUI EmbeddedData(EmbeddedDataType type, AudioPlayerFactory playerFactory = null) { return((Property property) => { var embeddedData = (EmbeddedData)property.value; GUILayout.BeginHorizontal(); AlignedLabel(property); if (GUILayout.Button(embeddedData.name, GUI.skin.textField)) { var import = GUIManager.guiGameObject.AddComponent <DataImportGUI>(); import.title = "Select " + property.name; import.type = type; import.playerFactory = playerFactory; import.dataAction = (data) => { property.value = data; }; } GUILayout.EndHorizontal(); }); }