/// <summary> /// Get all important information of EventInstance /// </summary> /// <param name="eventInstance">current EvnentInstance</param> private void GetEventInfo(EventInstance eventInstance) { ///Create EventDescription EventDescription eventDescription = new EventDescription(); eventInstance.getDescription(out eventDescription); ///Get min and max distance eventDescription.getMaximumDistance(out m_maxDistance); eventDescription.getMinimumDistance(out m_minumDistance); ///Get number of instance enabled eventDescription.getInstanceCount(out m_instanceCount); ///Check if has cue eventDescription.hasCue(out m_hasCue); eventInstance.getVolume(out m_volume, out m_maxVolume); ///Get all userPropery int _count; eventDescription.getUserPropertyCount(out _count); USER_PROPERTY[] userProperty = new USER_PROPERTY[_count]; m_userProperty = new string[_count]; for (int i = 0; i < _count; i++) { eventDescription.getUserPropertyByIndex(i, out userProperty[i]); m_userProperty[i] = userProperty[i].name + " | " + userProperty[i].stringValue(); } ///Check if is 3D or 2D bool _is3D = false; eventDescription.is3D(out _is3D); if (_is3D) { m_soundType = SoundType.is3D; } else { m_soundType = SoundType.is2D; } }
/// <summary> /// Get all important information of EventInstance /// </summary> /// <param name="eventInstance">current EvnentInstance</param> private void GetEventInfo(EventInstance eventInstance) { ///Create EventDescription EventDescription eventDescription = new EventDescription(); eventInstance.getDescription(out eventDescription); ///Get min and max distance eventDescription.getMaximumDistance(out m_maxDistance); eventDescription.getMinimumDistance(out m_minumDistance); //USER_PROPERTY ada; //int userPropertyCount; //eventDescription.getUserPropertyCount(out userPropertyCount); //Debug.Log(userPropertyCount); //for (int i = 0; i < userPropertyCount; i++) //{ // eventDescription.getUserPropertyByIndex(i, out ada); // Debug.Log(ada.name); //} ///Get number of instance enabled eventDescription.getInstanceCount(out m_instanceCount); ///Check if has cue eventDescription.hasCue(out m_hasCue); ///Check if is 3D or 2D bool _is3D = false; eventDescription.is3D(out _is3D); if (_is3D) { m_soundType = SoundType.is3D; } else { m_soundType = SoundType.is2D; } }
private void UpdateEventInfoList() { this.eventInfoList.Clear(); try { FMOD.Studio.ATTRIBUTES_3D aTTRIBUTES_3D; FMOD_Listener.THROW_ERRORS(FMOD_StudioSystem.instance.System.getListenerAttributes(0, out aTTRIBUTES_3D)); Vector3 b2 = aTTRIBUTES_3D.position.toUnityVector(); Bank[] array = null; FMOD_Listener.THROW_ERRORS(FMOD_StudioSystem.instance.System.getBankList(out array)); Bank[] array2 = array; for (int i = 0; i < array2.Length; i++) { Bank bank = array2[i]; try { EventDescription[] array3 = null; FMOD_Listener.THROW_ERRORS(bank.getEventList(out array3)); if (array3 != null) { EventDescription[] array4 = array3; for (int j = 0; j < array4.Length; j++) { EventDescription eventDescription = array4[j]; int num = 0; FMOD_Listener.THROW_ERRORS(eventDescription.getInstanceCount(out num)); if (num > 0) { FMOD_Listener.EventInfo item = default(FMOD_Listener.EventInfo); item.streamCount = 0; FMOD_Listener.THROW_ERRORS(eventDescription.getPath(out item.path)); if (FMOD_Listener.PathFilter.Length > 0) { bool flag = false; string[] pathFilter = FMOD_Listener.PathFilter; for (int k = 0; k < pathFilter.Length; k++) { string value = pathFilter[k]; if (!item.path.ToLowerInvariant().Contains(value)) { flag = true; break; } } if (flag) { goto IL_3F4; } } FMOD_Listener.THROW_ERRORS(eventDescription.getLength(out item.timelineLength)); FMOD_Listener.THROW_ERRORS(eventDescription.is3D(out item.is3D)); float num2 = 0f; FMOD_Listener.THROW_ERRORS(eventDescription.getMinimumDistance(out num2)); float num3 = 0f; FMOD_Listener.THROW_ERRORS(eventDescription.getMaximumDistance(out num3)); float num4 = num3 - num2; if (item.timelineLength > 0) { item.normalizedPositions = new List <float>(num); } else { item.normalizedPositions = null; } EventInstance[] array5 = null; FMOD_Listener.THROW_ERRORS(eventDescription.getInstanceList(out array5)); item.instances = new List <FMOD_Listener.EventInstanceInfo>(num); EventInstance[] array6 = array5; for (int l = 0; l < array6.Length; l++) { EventInstance eventInstance = array6[l]; try { if (FMOD_Listener.IsEventInstancePlaying(eventInstance)) { FMOD_Listener.EventInstanceInfo item2 = default(FMOD_Listener.EventInstanceInfo); float num5 = 0f; FMOD_Listener.THROW_ERRORS(eventInstance.getProperty(EVENT_PROPERTY.STREAM_COUNT, out num5)); item2.streamCount = (int)num5; item.streamCount += item2.streamCount; FMOD_Listener.THROW_ERRORS(eventInstance.get3DAttributes(out item2.attributes3D)); Vector3 a2 = item2.attributes3D.position.toUnityVector(); float num6 = Vector3.Distance(a2, b2); item2.distance = num6; item2.normalizedDistance = Mathf.Clamp01((num6 - num2) / num4); if (item.timelineLength > 0) { int num7 = 0; FMOD_Listener.THROW_ERRORS(eventInstance.getTimelinePosition(out num7)); item2.normalizedPosition = Mathf.Clamp01((float)num7 / (float)item.timelineLength); } else { item2.normalizedPosition = 0f; } int num8 = 0; FMOD_Listener.THROW_ERRORS(eventInstance.getParameterCount(out num8)); if (num8 > 0) { item2.parameters = new List <FMOD_Listener.ParameterInfo>(num8); for (int m = 0; m < num8; m++) { ParameterInstance parameterInstance; FMOD_Listener.THROW_ERRORS(eventInstance.getParameterByIndex(m, out parameterInstance)); PARAMETER_DESCRIPTION pARAMETER_DESCRIPTION; FMOD_Listener.THROW_ERRORS(parameterInstance.getDescription(out pARAMETER_DESCRIPTION)); float num9 = 0f; FMOD_Listener.THROW_ERRORS(parameterInstance.getValue(out num9)); float num10 = pARAMETER_DESCRIPTION.maximum - pARAMETER_DESCRIPTION.minimum; FMOD_Listener.ParameterInfo item3; item3.name = pARAMETER_DESCRIPTION.name; item3.value = num9; item3.normalizedValue = (num9 - pARAMETER_DESCRIPTION.minimum) / num10; item2.parameters.Add(item3); } item2.parameters.Sort(); } else { item2.parameters = null; } item.instances.Add(item2); if (item.normalizedPositions != null) { item.normalizedPositions.Add(item2.normalizedPosition); } } } catch (FMOD_Listener.FMODErrorException ex) { if (ex.Error != RESULT.ERR_INVALID_HANDLE) { UnityEngine.Debug.LogWarning(ex); } } } this.eventInfoList.Add(item); } IL_3F4 :; } } } catch (FMOD_Listener.FMODErrorException ex2) { if (ex2.Error != RESULT.ERR_INVALID_HANDLE) { UnityEngine.Debug.LogWarning(ex2); } } } this.eventInfoList.Sort((FMOD_Listener.EventInfo a, FMOD_Listener.EventInfo b) => string.Compare(a.path, b.path, StringComparison.InvariantCultureIgnoreCase)); } catch (FMOD_Listener.FMODErrorException message) { UnityEngine.Debug.LogWarning(message); } }