public static void TryAddONSPToAllAudioSources(bool newAudioSourcesOnly, bool includeInactive) { AudioSource[] allAudioSources = includeInactive ? Resources.FindObjectsOfTypeAll <AudioSource>() : Object.FindObjectsOfType <AudioSource>(); foreach (AudioSource src in allAudioSources) { if (src == null || src.gameObject == null || !src.enabled || src.gameObject.scene != UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene()) { continue; } if (newAudioSourcesOnly) { if (!IsNewAudioSource(src)) { continue; } src.spatialBlend = 1.0f; // set 3D mode UnityEngine.Audio.AudioMixerGroup mixer = AssetDatabase.LoadAssetAtPath <UnityEngine.Audio.AudioMixerGroup>("Assets/VRCSDK/Dependencies/OSPNative/scenes/mixers/SpatializerMixer.mixer"); if (mixer != null) { src.outputAudioMixerGroup = mixer; } } if (AddONSPAudioSourceComponent.ApplyDefaultSpatializationToAudioSource(src)) { Debug.Log("Automatically added ONSPAudioSource component and enabled spatialized audio to " + GetGameObjectPath(src.gameObject) + "!"); } } }
// Token: 0x060063F8 RID: 25592 RVA: 0x00237A90 File Offset: 0x00235E90 public static void ApplyDefaultSpatializationToAudioSources() { AudioSource[] array = UnityEngine.Object.FindObjectsOfType <AudioSource>(); foreach (AudioSource audioSrc in array) { AddONSPAudioSourceComponent.ApplyDefaultSpatializationToAudioSource(audioSrc); } }
// Token: 0x060063F9 RID: 25593 RVA: 0x00237AC4 File Offset: 0x00235EC4 public static bool ApplyDefaultSpatializationToAudioSource(AudioSource audioSrc) { if (audioSrc == null) { return(false); } if (!Mathf.Approximately(audioSrc.spatialBlend, 1f)) { return(false); } ONSPAudioSource onspaudioSource = audioSrc.GetComponent <ONSPAudioSource>(); if (onspaudioSource != null) { return(false); } onspaudioSource = audioSrc.gameObject.AddComponent <ONSPAudioSource>(); audioSrc.spatialize = true; onspaudioSource.EnableSpatialization = true; onspaudioSource.Gain = AddONSPAudioSourceComponent.SpatializeGainFactor; onspaudioSource.UseInvSqr = (audioSrc.rolloffMode != AudioRolloffMode.Linear); onspaudioSource.Near = ((audioSrc.rolloffMode == AudioRolloffMode.Custom) ? AddONSPAudioSourceComponent.CalculateCustomRolloffNearDistance(audioSrc) : audioSrc.minDistance); if (onspaudioSource.UseInvSqr) { onspaudioSource.Far = audioSrc.maxDistance * AddONSPAudioSourceComponent.InvSqrAttentuationMaxDistanceScale; } else { onspaudioSource.Far = audioSrc.maxDistance; } return(true); }
// Token: 0x06005BD5 RID: 23509 RVA: 0x00200B3C File Offset: 0x001FEF3C public IEnumerator ProcessSceneObjects(Action onDone) { List <Transform> rootTransforms = new List <Transform>(); Transform[] allTransforms = Tools.FindSceneObjectsOfTypeAll <Transform>(); foreach (Transform item in from t in allTransforms where t != null && t.parent == null && t.gameObject != null && !t.gameObject.CompareTag("VRCGlobalRoot") select t) { rootTransforms.Add(item); } yield return(null); if (!this.sceneDescriptor.useAssignedLayers) { foreach (Transform transform in rootTransforms) { try { Tools.SetLayerRecursively(transform.gameObject, LayerMask.NameToLayer("Environment"), LayerMask.NameToLayer("Interactive")); } catch (Exception exception) { Debug.LogException(exception, transform.gameObject); } } } else { Debug.Log("This level has elected to use it's own Unity Layers. If things like physics and collision are messed up, this is a likely reason."); } yield return(null); Physics.gravity = this.sceneDescriptor.gravity; Debug.Log("<color=yellow>Loading scene's render settings.</color>"); if (this.sceneDescriptor.layerCollisionArr != null) { bool[,] array = Tools.OneDArrayToTwoDArray <bool>(this.sceneDescriptor.layerCollisionArr, 32, 32); int numReservedLayers = Tools.GetNumReservedLayers(); for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { if (i >= numReservedLayers || j >= numReservedLayers) { bool ignore = !array[i, j]; if (i == LayerMask.NameToLayer("UI") || i == LayerMask.NameToLayer("UiMenu") || i == LayerMask.NameToLayer("StereoLeft") || i == LayerMask.NameToLayer("StereoRight") || j == LayerMask.NameToLayer("UI") || j == LayerMask.NameToLayer("UiMenu") || j == LayerMask.NameToLayer("StereoLeft") || j == LayerMask.NameToLayer("StereoRight")) { ignore = true; } Physics.IgnoreLayerCollision(i, j, ignore); } } } } yield return(null); VRC_SpecialLayer[] layers = Tools.FindSceneObjectsOfTypeAll <VRC_SpecialLayer>(); foreach (VRC_SpecialLayer vrc_SpecialLayer in from l in layers where l != null && !l.transform.root.gameObject.CompareTag("VRCGlobalRoot") select l) { try { vrc_SpecialLayer.Apply(); } catch (Exception exception2) { Debug.LogException(exception2, vrc_SpecialLayer.gameObject); } } yield return(null); VRCAudioManager.DisableAllExtraAudioListeners(); yield return(null); AudioSource[] audioSources = Tools.FindSceneObjectsOfTypeAll <AudioSource>(); foreach (AudioSource audioSource in audioSources) { VRCAudioManager.ApplyGameAudioMixerSettings(audioSource); } yield return(null); if (this.sceneDescriptor.autoSpatializeAudioSources) { Debug.Log("Auto spatializing AudioSources..."); try { AddONSPAudioSourceComponent.ApplyDefaultSpatializationToAudioSources(); } catch (Exception exception3) { Debug.LogException(exception3, this.sceneDescriptor.gameObject); } } yield return(null); onDone(); yield break; }