Пример #1
0
 private void OnDestroy()
 {
     //FMOD.Studio.PLAYBACK_STATE state;
     //FMOD.RESULT result = instance.getPlaybackState(out state);
     //if (result == FMOD.RESULT.OK && state == FMOD.Studio.PLAYBACK_STATE.PLAYING)
     EventInstance[] array;
     description.getInstanceList(out array);
     foreach (EventInstance inst in array)
     {
         inst.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
     }
 }
Пример #2
0
 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);
     }
 }