void Update() { if (studioSystem != null) { studioSystem.update(); if (!hasListener && !listenerWarningIssued) { listenerWarningIssued = true; UnityEngine.Debug.LogWarning("FMOD Studio Integration: Please add an 'FMOD Studio Listener' component to your a camera in the scene for correct 3D positioning of sounds"); } for (int i = 0; i < attachedInstances.Count; i++) { FMOD.Studio.PLAYBACK_STATE playbackState = FMOD.Studio.PLAYBACK_STATE.STOPPED; attachedInstances[i].instance.getPlaybackState(out playbackState); if (!attachedInstances[i].instance.isValid() || playbackState == FMOD.Studio.PLAYBACK_STATE.STOPPED || attachedInstances[i].transform == null // destroyed game object ) { attachedInstances.RemoveAt(i); i--; continue; } attachedInstances[i].instance.set3DAttributes(RuntimeUtils.To3DAttributes(attachedInstances[i].transform, attachedInstances[i].rigidBody)); } } }
void Update() { if (studioSystem.isValid()) { if (numListeners <= 0 && !listenerWarningIssued) { listenerWarningIssued = true; UnityEngine.Debug.LogWarning("[FMOD] Please add an 'FMOD Studio Listener' component to your a camera in the scene for correct 3D positioning of sounds."); } for (int i = 0; i < attachedInstances.Count; i++) { FMOD.Studio.PLAYBACK_STATE playbackState = FMOD.Studio.PLAYBACK_STATE.STOPPED; attachedInstances[i].instance.getPlaybackState(out playbackState); if (!attachedInstances[i].instance.isValid() || playbackState == FMOD.Studio.PLAYBACK_STATE.STOPPED || attachedInstances[i].transform == null // destroyed game object ) { attachedInstances.RemoveAt(i); i--; continue; } if (attachedInstances[i].rigidBody) { attachedInstances[i].instance.set3DAttributes(RuntimeUtils.To3DAttributes(attachedInstances[i].transform, attachedInstances[i].rigidBody)); } else { attachedInstances[i].instance.set3DAttributes(RuntimeUtils.To3DAttributes(attachedInstances[i].transform, attachedInstances[i].rigidBody2D)); } } #if UNITY_EDITOR MuteAllEvents(UnityEditor.EditorUtility.audioMasterMute); for (int i = eventPositionWarnings.Count - 1; i >= 0; i--) { if (eventPositionWarnings[i].isValid()) { FMOD.ATTRIBUTES_3D attribs; eventPositionWarnings[i].get3DAttributes(out attribs); if (attribs.position.x == 1e+18F && attribs.position.y == 1e+18F && attribs.position.z == 1e+18F) { string path; FMOD.Studio.EventDescription desc; eventPositionWarnings[i].getDescription(out desc); desc.getPath(out path); Debug.LogWarningFormat("[FMOD] Instance of Event {0} has not had EventInstance.set3DAttributes() called on it yet!", path); } } eventPositionWarnings.RemoveAt(i); } isOverlayEnabled = Settings.Instance.IsOverlayEnabled(fmodPlatform); #endif if (isOverlayEnabled) { if (!overlayDrawer) { overlayDrawer = Instance.gameObject.AddComponent <FMODRuntimeManagerOnGUIHelper>(); overlayDrawer.TargetRuntimeManager = this; } else { overlayDrawer.gameObject.SetActive(true); } } else { if (overlayDrawer != null && overlayDrawer.gameObject.activeSelf) { overlayDrawer.gameObject.SetActive(false); } } studioSystem.update(); } }
void Update() { #if UNITY_EDITOR _isOverlayEnabled = Settings.Instance.IsOverlayEnabled(fmodPlatform); #endif if (studioSystem.isValid() && _isOverlayEnabled) { if (_overlayDrawer == null) { GameObject overlayDrawer = new GameObject("FMODRunTimeManagerOverlayDrawer"); _overlayDrawer = overlayDrawer.AddComponent <FMODRuntimeManagerOnGUIHelper>(); _overlayDrawer.transform.SetParent(transform); _overlayDrawer.TargetRuntimeManager = this; } else { _overlayDrawer.gameObject.SetActive(true); } } else { if (_overlayDrawer != null && _overlayDrawer.gameObject.activeSelf) { _overlayDrawer.gameObject.SetActive(false); } } if (studioSystem.isValid()) { studioSystem.update(); bool foundListener = false; bool hasAllListeners = false; int numListeners = 0; for (int i = FMOD.CONSTANTS.MAX_LISTENERS - 1; i >= 0; i--) { if (!foundListener && HasListener[i]) { numListeners = i + 1; foundListener = true; hasAllListeners = true; } if (!HasListener[i] && foundListener) { hasAllListeners = false; } } if (foundListener) { studioSystem.setNumListeners(numListeners); } if (!hasAllListeners && !listenerWarningIssued) { listenerWarningIssued = true; UnityEngine.Debug.LogWarning("FMOD Studio Integration: Please add an 'FMOD Studio Listener' component to your a camera in the scene for correct 3D positioning of sounds"); } for (int i = 0; i < attachedInstances.Count; i++) { FMOD.Studio.PLAYBACK_STATE playbackState = FMOD.Studio.PLAYBACK_STATE.STOPPED; attachedInstances[i].instance.getPlaybackState(out playbackState); if (!attachedInstances[i].instance.isValid() || playbackState == FMOD.Studio.PLAYBACK_STATE.STOPPED || attachedInstances[i].transform == null // destroyed game object ) { attachedInstances.RemoveAt(i); i--; continue; } if (attachedInstances[i].rigidBody) { attachedInstances[i].instance.set3DAttributes(RuntimeUtils.To3DAttributes(attachedInstances[i].transform, attachedInstances[i].rigidBody)); } else { attachedInstances[i].instance.set3DAttributes(RuntimeUtils.To3DAttributes(attachedInstances[i].transform, attachedInstances[i].rigidBody2D)); } } #if UNITY_EDITOR MuteAllEvents(UnityEditor.EditorUtility.audioMasterMute); for (int i = eventPositionWarnings.Count - 1; i >= 0; i--) { if (eventPositionWarnings[i].isValid()) { FMOD.ATTRIBUTES_3D attribs; eventPositionWarnings[i].get3DAttributes(out attribs); if (attribs.position.x == 1e+18F && attribs.position.y == 1e+18F && attribs.position.z == 1e+18F) { string path; FMOD.Studio.EventDescription desc; eventPositionWarnings[i].getDescription(out desc); desc.getPath(out path); Debug.LogWarningFormat("FMOD Studio: Instance of Event {0} has not had EventInstance.set3DAttributes() called on it yet!", path); } } eventPositionWarnings.RemoveAt(i); } #endif } }
void Update() { if (studioSystem != null) { studioSystem.update(); bool foundListener = false; bool hasAllListeners = false; int numListeners = 0; for (int i = FMOD.CONSTANTS.MAX_LISTENERS - 1; i >= 0; i--) { if (!foundListener && HasListener[i]) { numListeners = i + 1; foundListener = true; hasAllListeners = true; } if (!HasListener[i] && foundListener) { hasAllListeners = false; } } if (foundListener) { studioSystem.setNumListeners(numListeners); } if (!hasAllListeners && !listenerWarningIssued) { listenerWarningIssued = true; UnityEngine.Debug.LogWarning("FMOD Studio Integration: Please add an 'FMOD Studio Listener' component to your a camera in the scene for correct 3D positioning of sounds"); } for (int i = 0; i < attachedInstances.Count; i++) { FMOD.Studio.PLAYBACK_STATE playbackState = FMOD.Studio.PLAYBACK_STATE.STOPPED; attachedInstances[i].instance.getPlaybackState(out playbackState); if (!attachedInstances[i].instance.isValid() || playbackState == FMOD.Studio.PLAYBACK_STATE.STOPPED || attachedInstances[i].transform == null // destroyed game object ) { attachedInstances.RemoveAt(i); i--; continue; } if (attachedInstances[i].rigidBody) { attachedInstances[i].instance.set3DAttributes(RuntimeUtils.To3DAttributes(attachedInstances[i].transform, attachedInstances[i].rigidBody)); } else { attachedInstances[i].instance.set3DAttributes(RuntimeUtils.To3DAttributes(attachedInstances[i].transform, attachedInstances[i].rigidBody2D)); } } #if UNITY_EDITOR MuteAllEvents(UnityEditor.EditorUtility.audioMasterMute); #endif #if UNITY_EDITOR // Catch any 3D events that are being played at the origin foreach (FMOD.Studio.EventDescription desc in cachedDescriptions.Values) { if (!desc.isValid()) { continue; } bool is3d; desc.is3D(out is3d); if (!is3d) { continue; } string path; desc.getPath(out path); int instanceCount; desc.getInstanceCount(out instanceCount); FMOD.Studio.EventInstance[] instances = new FMOD.Studio.EventInstance[instanceCount]; desc.getInstanceList(out instances); for (int i = 0; i < instances.Length; i++) { if (warnedInvalidInstances.ContainsKey(instances[i].getRaw())) { continue; } FMOD.ATTRIBUTES_3D attributes = new FMOD.ATTRIBUTES_3D(); instances[i].get3DAttributes(out attributes); if (attributes.position.x == 0 && attributes.position.y == 0 && attributes.position.z == 0) { warnedInvalidInstances.Add(instances[i].getRaw(), true); #if UNITY_5_X Debug.LogWarningFormat("FMOD Studio: Instance of Event {0} found playing at the origin. EventInstance.set3DAttributes() should be called on all 3D events", path); #else Debug.LogWarning(string.Format("FMOD Studio: Instance of Event {0} found playing at the origin. EventInstance.set3DAttributes() should be called on all 3D events", path)); #endif } } } #endif } }
void Update() { if (studioSystem != null) { studioSystem.update(); bool foundListener = false; bool hasAllListeners = false; int numListeners = 0; for (int i = FMOD.CONSTANTS.MAX_LISTENERS - 1; i >= 0; i--) { if (!foundListener && HasListener[i]) { numListeners = i + 1; foundListener = true; hasAllListeners = true; } if (!HasListener[i] && foundListener) { hasAllListeners = false; } } if (foundListener) { studioSystem.setNumListeners(numListeners); } if (!hasAllListeners && !listenerWarningIssued) { listenerWarningIssued = true; UnityEngine.Debug.LogWarning("FMOD Studio Integration: Please add an 'FMOD Studio Listener' component to your a camera in the scene for correct 3D positioning of sounds"); } for (int i = 0; i < attachedInstances.Count; i++) { FMOD.Studio.PLAYBACK_STATE playbackState = FMOD.Studio.PLAYBACK_STATE.STOPPED; attachedInstances[i].instance.getPlaybackState(out playbackState); if (!attachedInstances[i].instance.isValid() || playbackState == FMOD.Studio.PLAYBACK_STATE.STOPPED || attachedInstances[i].transform == null // destroyed game object ) { attachedInstances.RemoveAt(i); i--; continue; } if (attachedInstances[i].rigidBody) { attachedInstances[i].instance.set3DAttributes(RuntimeUtils.To3DAttributes(attachedInstances[i].transform, attachedInstances[i].rigidBody)); } else { attachedInstances[i].instance.set3DAttributes(RuntimeUtils.To3DAttributes(attachedInstances[i].transform, attachedInstances[i].rigidBody2D)); } } #if UNITY_EDITOR MuteAllEvents(UnityEditor.EditorUtility.audioMasterMute); #endif #if UNITY_EDITOR for (int i = eventPositionWarnings.Count - 1; i >= 0; i--) { if (eventPositionWarnings[i].isValid()) { FMOD.ATTRIBUTES_3D attribs; eventPositionWarnings[i].get3DAttributes(out attribs); if (attribs.position.x == float.MaxValue && attribs.position.y == float.MaxValue && attribs.position.z == float.MaxValue) { string path; FMOD.Studio.EventDescription desc; eventPositionWarnings[i].getDescription(out desc); desc.getPath(out path); #if UNITY_5 Debug.LogWarningFormat("FMOD Studio: Instance of Event {0} has not had EventInstance.set3DAttributes() called on it yet!", path); #else Debug.LogWarning(string.Format("FMOD Studio: Instance of Event {0} has not had EventInstance.set3DAttributes() called on it yet!", path)); #endif } } eventPositionWarnings.RemoveAt(i); } #endif } }