Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Defsine

Pages: [1]
1
TNet 3 Support / Re: Sound question
« on: October 27, 2016, 05:09:19 PM »
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.Audio;
  4.  
  5. public class SpawnedSoundObject : MonoBehaviour
  6. {
  7.     private AudioClip audioClip = null;
  8.     private AudioSource audioSource = null;
  9.                                                             //Audio Filters  
  10.     public float distortionLevel = 0.0f;                    //Distortion
  11.     public float lowPassCutoff = 0.0f;                      //Low Pass Filter
  12.     public float lowPassRes = 0.0f;                         //Low Pass Resonance                                                          
  13.     public float highPassCutoff = 0.0f;                     //High Pass Cuttoff                  
  14.     public float highPassRes = 0.0f;                        //High Pass Res
  15.     public int HighPassFilterOff;                           //HighPassFilter On/Off
  16.     public int LowPassFilterOff;                            //LowPassFilter On/Off
  17.     public int ReverbOff = 0;                               //Reverb On/Off
  18.     public int ReverbPreset = 0;                            //Reverb Preset
  19.     public int SpatialBlend = 0;
  20.     public float spread = 0.0f;
  21.     public float pitch = 1.0f;
  22.     public float volume = 1.0f;
  23.     public float minDistance = 0.5f;
  24.     public float maxDistance = 80.0f;
  25.     public float dopplerLevel = 0.1f;
  26.     public int   loopCount = 0;
  27.    
  28.     public int RolloffMode = 0;
  29.     public float DelaySound = 0.0f;
  30.  
  31.  
  32.     //AudioMixer
  33.     public int CleanMixer = 0;    
  34.     public int RadioMixer = 0;
  35.     public int AmbienceMixer = 0;
  36.  
  37.     //AudioMixer SnapShots
  38.     //public int Radio = 0;
  39.     //public int Natural = 0;
  40.  
  41.    
  42.  
  43.     private void OnDestroy()
  44.     {
  45.         if (audioClip != null)
  46.         {
  47.             //Set the mixer to be with no effects
  48.             //AudioMixer mixer = Resources.Load("MainGen4Mixer") as AudioMixer;
  49.             //AudioMixerSnapshot DrySnapShot = mixer.FindSnapshot("Dry");
  50.             //DrySnapShot.TransitionTo(0.01f);
  51.             DestroyImmediate(audioClip);
  52.             audioClip = null;
  53.         }
  54.     }
  55.    
  56.     public void LoadFromFile(string file)
  57.     {
  58.         Debug.Log("SpawnedSoundObject.LoadFromFile " + file);
  59.         StartCoroutine(LoadSoundFromFileRoutine(file));
  60.     }
  61.  
  62.     private IEnumerator LoadSoundFromFileRoutine(string file)
  63.     {
  64.         WWW fileLoad = new WWW(file);
  65.         yield return fileLoad;
  66.         if (!string.IsNullOrEmpty(fileLoad.error))
  67.         {
  68.             Debug.LogError("Failed to load Sound file " + file);
  69.             yield break;
  70.         }
  71.  
  72.         Debug.Log("Done Sound LoadFromFile " + file);
  73.  
  74.         audioClip = fileLoad.GetAudioClip(true);
  75.  
  76.         StartCoroutine(PlayClip());
  77.     }
  78.  
  79.     private IEnumerator PlayClip()
  80.     {
  81.         if (audioClip)
  82.         {
  83.  
  84.             //Here we get a refrence to our audio mixer
  85.             AudioMixer mixer = Resources.Load("UndergroundMixer") as AudioMixer;
  86.             string _outPutMixer = "UndergroundMixer";          
  87.             //Get our audio source
  88.             audioSource = gameObject.AddComponent<AudioSource>();
  89.             //We plugg out audio source into the Mixer Group
  90.             audioSource.outputAudioMixerGroup = mixer.FindMatchingGroups(_outPutMixer)[0];
  91.  
  92.             //Get a refrence to our audio mixer
  93.             AudioMixer mixer = Resources.Load("MainGen4Mixer") as AudioMixer;
  94.             string _outPutMixer = "MainGen4Group";
  95.             //Refrence to the radio mixer
  96.             AudioMixer radioMixer = Resources.Load("RadioMixer") as AudioMixer;
  97.             string _outPutRadioMixer = "RadioMixer";
  98.             //Refrence to the ambience mixer for ambience sounds
  99.             AudioMixer ambienceMixer = Resources.Load("AmbienceMixer") as AudioMixer;
  100.             string _outPutAmbienceMixer = "AmbienceMixer";
  101.  
  102.            
  103.             //we set our audiomixer update mode to normal
  104.             //mixer.updateMode = AudioMixerUpdateMode.Normal;
  105.                        
  106.  
  107.            
  108.             audioSource = gameObject.AddComponent<AudioSource>();          
  109.  
  110.  
  111.             audioSource = gameObject.AddComponent<AudioSource>();
  112.             //Plugg audio source into the Mixer Group
  113.             if (CleanMixer == 1)
  114.             {
  115.                 audioSource.outputAudioMixerGroup = mixer.FindMatchingGroups(_outPutMixer)[0];
  116.             }
  117.  
  118.             if (RadioMixer == 1)
  119.             {
  120.                 audioSource.outputAudioMixerGroup = radioMixer.FindMatchingGroups(_outPutRadioMixer)[0];
  121.             }
  122.  
  123.             if (AmbienceMixer == 1)
  124.             {
  125.                 Debug.Log("Ambience mixer is on");
  126.                 audioSource.outputAudioMixerGroup = ambienceMixer.FindMatchingGroups(_outPutAmbienceMixer)[0];
  127.             }
  128.  
  129.  
  130.             //Set our audiomixer update mode to normal
  131.             //mixer.updateMode = AudioMixerUpdateMode.Normal;
  132.  
  133.  
  134.             audioSource.volume = volume;
  135.             audioSource.rolloffMode = AudioRolloffMode.Linear;
  136.             audioSource.minDistance = minDistance;
  137.             audioSource.maxDistance = maxDistance;
  138.             audioSource.clip = audioClip;
  139.             audioSource.spatialBlend = 1.0f;            
  140.             audioSource.dopplerLevel = dopplerLevel;
  141.     audioSource.PlayDelayed(DelaySound);
  142.             audioSource.spread = spread;
  143.             audioSource.pitch = pitch;
  144.            
  145.  
  146.             if (RolloffMode == 1)
  147.             {
  148.                 audioSource.rolloffMode = AudioRolloffMode.Logarithmic;
  149.                
  150.             }
  151.  
  152.             if(SpatialBlend == 1)
  153.             {
  154.                 audioSource.spatialBlend = 0.0f;
  155.             }
  156.  
  157.            
  158.             //Distortion
  159.  
  160.             AudioDistortionFilter distortion = gameObject.AddComponent(typeof(AudioDistortionFilter)) as AudioDistortionFilter;
  161.             distortion.distortionLevel = distortionLevel;
  162.             //Low Pass Filter and High Pass Filter
  163.             AudioLowPassFilter lowPassFilter = gameObject.AddComponent(typeof(AudioLowPassFilter)) as AudioLowPassFilter;
  164.             AudioHighPassFilter highPassFilter = gameObject.AddComponent(typeof(AudioHighPassFilter)) as AudioHighPassFilter;
  165.             if (LowPassFilterOff == 0)
  166.             {
  167.                 Debug.Log("LowPassFilter is Off");
  168.                 lowPassFilter.enabled = false;                
  169.             }
  170.             else if (LowPassFilterOff == 1)
  171.             {
  172.                 Debug.Log("LowPassFilter is On");
  173.                 lowPassFilter.enabled = true;
  174.                 lowPassFilter.cutoffFrequency = lowPassCutoff;
  175.                 lowPassFilter.lowpassResonanceQ = lowPassRes;
  176.             }
  177.             if (HighPassFilterOff == 0)
  178.             {
  179.                 Debug.Log("HighPassFilter is Off");
  180.                 highPassFilter.enabled = false;                
  181.             }
  182.             else if (HighPassFilterOff == 1)
  183.             {
  184.                 Debug.Log("HighPassFilter is On");
  185.                 highPassFilter.enabled = true;
  186.                 highPassFilter.cutoffFrequency = highPassCutoff;
  187.                 highPassFilter.highpassResonanceQ = highPassRes;
  188.             }
  189.             //Reverb Filter
  190.             AudioReverbFilter reverFilter = gameObject.AddComponent(typeof(AudioReverbFilter)) as AudioReverbFilter;
  191.             if (ReverbOff == 0)
  192.             {
  193.                 Debug.Log("Reverb Filter is Off");
  194.                 reverFilter.enabled = false;
  195.             }
  196.             else if (ReverbOff == 1)
  197.             {
  198.                 Debug.Log("Reverb Filter is On");
  199.                 reverFilter.enabled = true;
  200.             }
  201.             //Reverb Presets
  202.             if (ReverbPreset == 1)
  203.             {
  204.                 reverFilter.reverbPreset = AudioReverbPreset.Cave;
  205.             }
  206.             if (ReverbPreset == 2)
  207.             {
  208.                 reverFilter.reverbPreset = AudioReverbPreset.Hangar;
  209.             }
  210.             if (ReverbPreset == 3)
  211.             {
  212.                 reverFilter.reverbPreset = AudioReverbPreset.Mountains;
  213.             }
  214.             if (ReverbPreset == 4)
  215.             {
  216.                 reverFilter.reverbPreset = AudioReverbPreset.Stoneroom;
  217.             }
  218.             if (ReverbPreset == 5)
  219.             {
  220.                 reverFilter.reverbPreset = AudioReverbPreset.Quarry;
  221.             }
  222.             if (ReverbPreset == 6)
  223.             {
  224.                 reverFilter.reverbPreset = AudioReverbPreset.Room;
  225.             }
  226.             if (ReverbPreset == 7)
  227.             {
  228.                 reverFilter.reverbPreset = AudioReverbPreset.StoneCorridor;
  229.             }
  230.             if (ReverbPreset == 8)
  231.             {
  232.                 reverFilter.reverbPreset = AudioReverbPreset.Generic;
  233.             }
  234.             //Audio MixerSnap Shots
  235.            // if (Radio == 1)
  236.             //{
  237.             //    AudioMixerSnapshot RadioSnapShot = mixer.FindSnapshot("Radio");
  238.             //    RadioSnapShot.TransitionTo(.01f);
  239.             //    Debug.Log("Radio Sound On");
  240.            // }
  241.  
  242.             if (loopCount < 0)
  243.             {
  244.                 audioSource.loop = true;
  245.                 audioSource.Play();
  246.                 yield break;
  247.             }
  248.             else if (loopCount == 0)
  249.             {
  250.                 audioSource.PlayOneShot(audioClip);
  251.  
  252.                 yield return null;
  253.                 while (audioSource.isPlaying) yield return null;
  254.             }
  255.             else
  256.             {
  257.                 audioSource.loop = true;
  258.                 audioSource.Play();
  259.  
  260.                 yield return new WaitForSeconds((audioClip.length * 0.5f) + (audioClip.length * (loopCount - 1)));
  261.                 audioSource.loop = false;
  262.                 while (audioSource.isPlaying) yield return null;
  263.             }
  264.  
  265.             Destroy(gameObject);
  266.         }
  267.     }
  268. }

2
TNet 3 Support / Re: Sound question
« on: October 27, 2016, 05:06:01 PM »
  1. using UnityEngine;
  2. using System.Collections.Generic;
  3.  
  4. public class SoundManager : MonoBehaviour
  5. {
  6.     private const byte RFC_PlaySoundFromFile = 218;
  7.  
  8.     private const string RockMLCommandTypePlaySound = "PlaySound";
  9.     private const string RockMLArgName = "Name";
  10.     private const string RockMLArgFile = "File";
  11.     private const string RockMLArgPosX = "PosX";
  12.     private const string RockMLArgPosY = "PosY";
  13.     private const string RockMLArgPosZ = "PosZ";
  14.     private const string RockMLArgMinDistance = "MinDistance";
  15.     private const string RockMLArgMaxDistance = "MaxDistance";
  16.     private const string RockMLArgVolume = "Volume";
  17.     private const string RockMLArgDopplerLevel = "DopplerLevel";
  18.     private const string RockMLArgLoopCount = "LoopCount";
  19.     private const string RockMLArgDistortionLvl = "DistortionLvl";
  20.     private const string RockMLArglowPassCutoff = "LowPassCutoff";
  21.     private const string RockMLArglowPassRes = "LowPassRes";
  22.     private const string RockMLArgHighPassCutoff = "HighPassCutoff";
  23.     private const string RockMLArgHighPassRes = "HighPassRes";
  24.     private const string RockMLArgHighPassFilterOn = "HPF";
  25.     private const string RockMLArgLowPassFilterOn = "LPF";
  26.     private const string RockMLArgReverbFilterOn = "Reverb";
  27.     private const string RockMLArgReverbType = "ReverbType";
  28.     private const string RockMLArgLog = "LogRollOff";
  29.     private const string RockMLArgDelaySound = "DelaySound";
  30.     private const string RockMLArgSpatialBlend = "2DSound";
  31.     private const string RockMLArgSpread = "Spread";
  32.     private const string RockMLArgPitch = "Pitch";
  33.  
  34.  
  35.     //AudioMixer
  36.     private const string RockMLArgUseAudioMixer = "CleanMixer";
  37.     private const string RockMLArgRadioEffect = "RadioMixer";
  38.     private const string RockMLArgAmbienceMixer = "AmbienceMixer";
  39.  
  40.  
  41.  
  42.     public static bool VoiceCommsActive = true;
  43.     public static bool VoiceCommsCanSend = true;
  44.     public static bool VoiceCommsCanReceive = true;
  45.     public static bool VoiceReliableSend = false;
  46.     public static int VoiceSendChunkSize = 640;
  47.     public static float VoiceSendVolume = 1.0f;
  48.     public static float VoiceReceiveVolume = 1.0f;
  49.  
  50.     public static Dictionary<string, SpawnedSoundObject> SoundObjects = new Dictionary<string, SpawnedSoundObject>(4);
  51.  
  52.     public static SoundManager Instance = null;
  53.  
  54.     private TNObject tnObject = null;
  55.  
  56.     private void Awake()
  57.     {
  58.         Instance = this;
  59.         tnObject = GetComponent<TNObject>();
  60.  
  61.         if (SimManager.IsHost)
  62.         {
  63.             if (RMLComms.Instance == null) RMLComms.Initialise();
  64.             RMLComms.Instance.RegisterHandler(RockMLCommandTypePlaySound, PlaySoundCommand);
  65.         }
  66.  
  67.         DebugManager.TimerStart();
  68.         VoiceCommsHandler(null, null, null);
  69.         Config.Instance.RegisterHandler(Config.ALLOWVOICECOMMS, VoiceCommsHandler);
  70.         Config.Instance.RegisterHandler(Config.VOICESENDVOLUME, VoiceCommsHandler);
  71.         Config.Instance.RegisterHandler(Config.VOICERECEIVEVOLUME, VoiceCommsHandler);
  72.         Config.Instance.RegisterHandler(Config.VOICERELIABLESEND, VoiceCommsHandler);
  73.         Config.Instance.RegisterHandler(Config.VOICESENDCHUNKSIZE, VoiceCommsHandler);
  74.         DebugManager.TimerEnd("Startup Timer: HUDManager Init: ");
  75.     }
  76.  
  77.     private void VoiceCommsHandler(string key, string value, string oldValue)
  78.     {
  79.         Config.Instance.GetValueBool(Config.ALLOWVOICECOMMS, ref VoiceCommsActive);
  80.         Config.Instance.GetValueFloat(Config.VOICESENDVOLUME, ref VoiceSendVolume);
  81.         Config.Instance.GetValueFloat(Config.VOICERECEIVEVOLUME, ref VoiceReceiveVolume);
  82.         Config.Instance.GetValueBool(Config.VOICERELIABLESEND, ref VoiceReliableSend);
  83.         Config.Instance.GetValueInt(Config.VOICESENDCHUNKSIZE, ref VoiceSendChunkSize);
  84.     }
  85.  
  86.     public static void PlaySoundCommand(RockML.Command command)
  87.     {
  88.         string soundName = null;
  89.         string file = null;
  90.         float posX = 0.0f;
  91.         float posY = 0.0f;
  92.         float posZ = 0.0f;
  93.         float minDistance = 0.5f;
  94.         float maxDistance = 80.0f;
  95.         float volume = 1.0f;
  96.         float dopplerLevel = 0.1f;
  97.         int loopCount = 0;
  98.         float distortionLvl = 0.0f;                         //Distortion
  99.         float lowPassCutoff = 0.0f;                         //Low Pass Filter
  100.         float lowPassRes = 0.0f;                            //Low Pass Resonance                                                          //High Pass Filter
  101.         float highPassCutoff = 0.0f;                        //High Pass Cuttoff                  
  102.         float highPassRes = 0.0f;                           //High Pass Res
  103.         int hpf = 0;                                        //High Pass Filter On/Off
  104.         int lpf = 0;                                        //Low Pass Filter On/Off
  105.         int reverb = 0;                                     //Turn Reverb On/Off
  106.         int reverbType = 0;
  107.         int radio = 0;
  108.         int mixer = 0;
  109.         int rollOffLog = 0;
  110.         int ambienceMix = 0;
  111.         float delaySound = 0;
  112.         int spatialBlend = 0;
  113.         float spread = 0;
  114.         float pitch = 1.0f;
  115.  
  116.  
  117.  
  118.     int numArguments = command.arguments.Count;
  119.         for (int i = 0; i < numArguments; i++)
  120.         {
  121.             string key = command.arguments[i].name;
  122.             switch (key)
  123.             {
  124.                 case RockMLArgName:
  125.                     soundName = command.arguments[i].value;
  126.                     break;
  127.  
  128.                 case RockMLArgFile:
  129.                     file = command.arguments[i].value;
  130.                     if (!file.Contains(":/") && !file.Contains(":\\"))
  131.                     {
  132.                         file = RMLComms.CurrentScenarioPathWithFilePrefix + file.Replace('/', '\\');
  133.                     }
  134.                     break;
  135.  
  136.                 case RockMLArgPosX:
  137.                     float.TryParse(command.arguments[i].value, out posX);
  138.                     break;
  139.  
  140.                 case RockMLArgPosY:
  141.                     float.TryParse(command.arguments[i].value, out posY);
  142.                     break;
  143.  
  144.                 case RockMLArgPosZ:
  145.                     float.TryParse(command.arguments[i].value, out posZ);
  146.                     break;
  147.  
  148.                 case RockMLArgMinDistance:
  149.                     float.TryParse(command.arguments[i].value, out minDistance);
  150.                     break;
  151.  
  152.                 case RockMLArgMaxDistance:
  153.                     float.TryParse(command.arguments[i].value, out maxDistance);
  154.                     break;
  155.  
  156.                 case RockMLArgVolume:
  157.                     float.TryParse(command.arguments[i].value, out volume);
  158.                     break;
  159.  
  160.                 case RockMLArgDopplerLevel:
  161.                     float.TryParse(command.arguments[i].value, out dopplerLevel);
  162.                     break;
  163.  
  164.                 case RockMLArgLoopCount:
  165.                     int.TryParse(command.arguments[i].value, out loopCount);
  166.                     break;
  167.  
  168.                 case RockMLArgDistortionLvl:  
  169.                     float.TryParse(command.arguments[i].value, out distortionLvl);
  170.                     break;
  171.  
  172.                 case RockMLArglowPassCutoff:  
  173.                     float.TryParse(command.arguments[i].value, out lowPassCutoff);
  174.                     break;
  175.  
  176.                 case RockMLArglowPassRes:
  177.                     float.TryParse(command.arguments[i].value, out lowPassRes);
  178.                     break;
  179.  
  180.                 case RockMLArgHighPassCutoff:
  181.                     float.TryParse(command.arguments[i].value, out highPassCutoff);
  182.                     break;
  183.  
  184.                 case RockMLArgHighPassRes:
  185.                     float.TryParse(command.arguments[i].value, out highPassRes);
  186.                     break;
  187.  
  188.                 case RockMLArgHighPassFilterOn:
  189.                     int.TryParse(command.arguments[i].value, out hpf);
  190.                     break;
  191.  
  192.                 case RockMLArgLowPassFilterOn:
  193.                     int.TryParse(command.arguments[i].value, out lpf);
  194.                     break;
  195.  
  196.                 case RockMLArgReverbFilterOn:
  197.                     int.TryParse(command.arguments[i].value, out reverb);
  198.                     break;
  199.  
  200.                 case RockMLArgReverbType:
  201.                     int.TryParse(command.arguments[i].value, out reverbType);
  202.                     break;
  203.  
  204.                 case RockMLArgRadioEffect:
  205.                     int.TryParse(command.arguments[i].value, out radio);
  206.                     break;
  207.  
  208.                 case RockMLArgUseAudioMixer:
  209.                     int.TryParse(command.arguments[i].value, out mixer);
  210.                     break;
  211.  
  212.                 case RockMLArgLog:
  213.                     int.TryParse(command.arguments[i].value, out rollOffLog);
  214.                     break;
  215.  
  216.                 case RockMLArgAmbienceMixer:
  217.                     int.TryParse(command.arguments[i].value, out ambienceMix);
  218.                     break;
  219.  
  220.                 case RockMLArgDelaySound:
  221.                     float.TryParse(command.arguments[i].value, out delaySound);
  222.                     break;
  223.  
  224.                 case RockMLArgSpatialBlend:
  225.                     int.TryParse(command.arguments[i].value, out spatialBlend);
  226.                     break;
  227.  
  228.                 case RockMLArgSpread:
  229.                     float.TryParse(command.arguments[i].value, out spread);
  230.                     break;
  231.  
  232.                 case RockMLArgPitch:
  233.                     float.TryParse(command.arguments[i].value, out pitch);
  234.                     break;
  235.  
  236.                 default:
  237.                     break;
  238.             }
  239.         }
  240.  
  241.         if (file != null)
  242.         {
  243.             Vector3 pos = new Vector3(posX, posY, posZ);
  244.             if (file != null)
  245.             {
  246.                 SpawnedSoundObject spawnedSoundOb = Instance.DoPlaySoundFromFile(file,
  247.                     pos,
  248.                     minDistance,
  249.                     maxDistance,
  250.                     volume,
  251.                     dopplerLevel,
  252.                     loopCount,
  253.                     distortionLvl,
  254.                     lowPassCutoff,
  255.                     lowPassRes,
  256.                     highPassCutoff,
  257.                     highPassRes,
  258.                     lpf,
  259.                     hpf,
  260.                     reverb,
  261.                     reverbType,
  262.                     radio,
  263.                     mixer,
  264.                     rollOffLog,
  265.                     ambienceMix,
  266.                     delaySound,
  267.                     spatialBlend,
  268.                     spread,
  269.                     pitch);
  270.  
  271.                 if (TNManager.players.Count > 0) Instance.tnObject.Send(RFC_PlaySoundFromFile,
  272.                     TNet.Target.Others,
  273.                     file,
  274.                     pos,
  275.                     minDistance,
  276.                     maxDistance,
  277.                     volume,
  278.                     dopplerLevel,
  279.                     loopCount,
  280.                     distortionLvl,
  281.                     lowPassCutoff,
  282.                     lowPassRes,
  283.                     highPassCutoff,
  284.                     highPassRes,
  285.                     lpf,
  286.                     hpf,
  287.                     reverb,
  288.                     reverbType,
  289.                     radio,
  290.                     mixer,
  291.                     rollOffLog,
  292.                     ambienceMix,
  293.                     delaySound,
  294.                     spatialBlend,
  295.                     spread,
  296.                     pitch);
  297.  
  298.                 if (soundName != null)
  299.                 {
  300.                     SoundObjects[soundName] = spawnedSoundOb;
  301.                 }
  302.             }
  303.         }
  304.         else
  305.         {
  306.             Debug.LogWarning("No file given in PlaySound command");
  307.         }
  308.     }
  309.  
  310.     [TNet.RFC(RFC_PlaySoundFromFile)]
  311.     public void PlaySoundFromFile(
  312.         string soundFile,
  313.         Vector3 pos,
  314.         float minDistance,
  315.         float maxDistance,
  316.         float volume,
  317.         float dopplerLevel,
  318.         int loopCount,
  319.         float distortionLvl,
  320.         float lowPassCutoff,
  321.         float lowPassRes,
  322.         float highPassCutoff,
  323.         float highPassRes,
  324.         int lpf,
  325.         int hpf,
  326.         int reverb,
  327.         int reverbType,
  328.         int radio,
  329.         int mixer,
  330.         int rollOffLog,
  331.         int ambienceMix,
  332.         float delaySound,
  333.         int spatialBlend,
  334.         float spread,
  335.         float pitch)
  336.     {
  337.         DoPlaySoundFromFile(
  338.             soundFile,
  339.             pos,
  340.             minDistance,
  341.             maxDistance,
  342.             volume,
  343.             dopplerLevel,
  344.             loopCount,
  345.             distortionLvl,
  346.             lowPassCutoff,
  347.             lowPassRes,
  348.             highPassCutoff,
  349.             highPassRes,
  350.             lpf,
  351.             hpf,
  352.             reverb,
  353.             reverbType,
  354.             radio,
  355.             mixer,
  356.             rollOffLog,
  357.             ambienceMix,
  358.             delaySound,
  359.             spatialBlend,
  360.             spread,
  361.             pitch);
  362.     }
  363.  
  364.     public SpawnedSoundObject DoPlaySoundFromFile(
  365.         string soundFile,
  366.         Vector3 pos,
  367.         float minDistance,
  368.         float maxDistance,
  369.         float volume,
  370.         float dopplerLevel,
  371.         int loopCount,
  372.         float distortionLvl,
  373.         float lowPassCutoff,
  374.         float lowPassRes,
  375.         float highPassCutoff,
  376.         float highPassRes,
  377.         int lpf,
  378.         int hpf,
  379.         int reverb,
  380.         int reverbType,
  381.         int radio,
  382.         int mixer,
  383.         int rollOffLog,
  384.         int ambienceMix,
  385.         float delaySound,
  386.         int spatialBlend,
  387.         float spread,
  388.         float pitch)
  389.     {
  390.         GameObject soundOb = new GameObject();
  391.         SpawnedSoundObject spawnedSoundObject = soundOb.AddComponent<SpawnedSoundObject>();
  392.         spawnedSoundObject.transform.position = pos;
  393.         spawnedSoundObject.volume = volume;
  394.         spawnedSoundObject.minDistance = minDistance;
  395.         spawnedSoundObject.maxDistance = maxDistance;
  396.         spawnedSoundObject.dopplerLevel = dopplerLevel;
  397.         spawnedSoundObject.loopCount = loopCount;
  398.         spawnedSoundObject.distortionLevel = distortionLvl;
  399.         spawnedSoundObject.lowPassCutoff = lowPassCutoff;
  400.         spawnedSoundObject.lowPassRes = lowPassRes;
  401.         spawnedSoundObject.highPassCutoff = highPassCutoff;
  402.         spawnedSoundObject.highPassRes = highPassRes;
  403.         spawnedSoundObject.HighPassFilterOff = hpf;
  404.         spawnedSoundObject.LowPassFilterOff = lpf;
  405.         spawnedSoundObject.ReverbOff = reverb;
  406.         spawnedSoundObject.ReverbPreset = reverbType;
  407.         spawnedSoundObject.RadioMixer = radio;
  408.         spawnedSoundObject.CleanMixer = mixer;
  409.         spawnedSoundObject.RolloffMode = rollOffLog;
  410.         spawnedSoundObject.AmbienceMixer = ambienceMix;
  411.         spawnedSoundObject.DelaySound = delaySound;
  412.         spawnedSoundObject.SpatialBlend = spatialBlend;
  413.         spawnedSoundObject.spread = spread;
  414.         spawnedSoundObject.pitch = pitch;
  415.         spawnedSoundObject.LoadFromFile(soundFile);
  416.  
  417.         return spawnedSoundObject;
  418.     }
  419. }
  420.  

Pages: [1]