public virtual void SetExternAudioFile(ExternAudioFile p_externAudio) { if (p_externAudio != null) { Key = p_externAudio.Url; Clip = p_externAudio.Clip; } }
protected override void Apply() { if (AudioSourceComponent != null) { var v_isDownloading = ExternalResources.IsDownloading(Key); if (string.IsNullOrEmpty(Key) || !v_isDownloading || (_canUnregisterOnDisable && v_isDownloading)) //someone called this request before this external image { ExternAudioFile v_callback = !ExternalResources.IsLoaded(Key) ? ExternalResources.ReloadClipAsync(Key, ApplyClip) : ExternalResources.LoadClipAsync(Key, ApplyClip); if (v_callback != null) { if (v_callback.IsProcessing()) { //Reset image if (Clip != null) { ApplyEmptyClipInAudioSourceComponent(); } _canUnregisterOnDisable = false; if (OnRequestDownloadClipCallback != null) { OnRequestDownloadClipCallback.Invoke(); } } else { HandleOnAudioLoaded(v_callback); } } } else { if (Clip != null) { ApplyEmptyClipInAudioSourceComponent(); } SetDirty(); } } }
protected virtual void HandleOnAudioLoaded(ExternAudioFile p_audio) { if ((string.IsNullOrEmpty(Key) && (p_audio == null || string.IsNullOrEmpty(p_audio.Url))) || (p_audio != null && string.Equals(p_audio.Url, Key))) { if (AudioSourceComponent != null && !string.IsNullOrEmpty(Key) && p_audio.Clip != null) { Clip = p_audio.Clip; } if (OnApplyClipCallback != null) { OnApplyClipCallback.Invoke(); } if (!_canUnregisterOnDisable) { _canUnregisterOnDisable = true; if (!gameObject.activeInHierarchy || !gameObject.activeSelf || !enabled) { UnregisterEvents(); } } _isDirty = false; } }