55using System . Collections . Generic ;
66using UnityEngine ;
77using UnityEngine . Audio ;
8+ using UnityEditor ;
9+ using UnityEditor . Audio ;
10+ using System . IO ;
811using System ;
912using System . Linq ;
13+
1014using Object = UnityEngine . Object ;
1115
1216namespace UnityEditor . Audio
@@ -37,13 +41,18 @@ public override string ResolveStringPath(bool getOnlyBasePath)
3741 {
3842 return "Volume" + GetBasePath ( group . GetDisplayString ( ) , null ) ;
3943 }
40-
41- if ( group . GetGUIDForPitch ( ) == parameter )
44+ else if ( group . GetGUIDForPitch ( ) == parameter )
4245 {
4346 return "Pitch" + GetBasePath ( group . GetDisplayString ( ) , null ) ;
4447 }
45-
46- return "Error finding parameter path." ;
48+ else if ( group . GetGUIDForSend ( ) == parameter )
49+ {
50+ return "Send" + GetBasePath ( group . GetDisplayString ( ) , null ) ;
51+ }
52+ else
53+ {
54+ return "Error finding Parameter path." ;
55+ }
4756 }
4857
4958 protected string GetBasePath ( string group , string effect )
@@ -73,29 +82,22 @@ public override string ResolveStringPath(bool getOnlyBasePath)
7382
7483 if ( effect . GetGUIDForMixLevel ( ) == parameter )
7584 {
76- if ( effect . IsSend ( ) )
77- {
78- var allGroups = group . controller . GetAllAudioGroupsSlow ( ) ;
79- var effectMap = AudioMixerGroupController . GetEffectMapSlow ( allGroups ) ;
80- return $ "Send level{ GetBasePath ( group . GetDisplayString ( ) , null ) } to { effect . sendTarget . GetDisplayString ( effectMap ) } ";
81- }
82-
83- return $ "Mix Level{ GetBasePath ( group . GetDisplayString ( ) , effect . effectName ) } ";
85+ return "Mix Level" + GetBasePath ( group . GetDisplayString ( ) , effect . effectName ) ;
8486 }
85-
86- MixerParameterDefinition [ ] paramDefs = MixerEffectDefinitions . GetEffectParameters ( effect . effectName ) ;
87-
88- for ( int i = 0 ; i < paramDefs . Length ; i ++ )
87+ else
8988 {
90- GUID guid = effect . GetGUIDForParameter ( paramDefs [ i ] . name ) ;
91-
92- if ( guid == parameter )
89+ MixerParameterDefinition [ ] paramDefs = MixerEffectDefinitions . GetEffectParameters ( effect . effectName ) ;
90+ for ( int i = 0 ; i < paramDefs . Length ; i ++ )
9391 {
94- return paramDefs [ i ] . name + GetBasePath ( group . GetDisplayString ( ) , effect . effectName ) ;
92+ GUID guid = effect . GetGUIDForParameter ( paramDefs [ i ] . name ) ;
93+ if ( guid == parameter )
94+ {
95+ return paramDefs [ i ] . name + GetBasePath ( group . GetDisplayString ( ) , effect . effectName ) ;
96+ }
9597 }
96- }
9798
98- return "Error finding parameter path." ;
99+ return "Error finding Parameter path." ;
100+ }
99101 }
100102 }
101103
@@ -105,12 +107,11 @@ public override string ResolveStringPath(bool getOnlyBasePath)
105107 internal sealed partial class AudioMixerController : AudioMixer
106108 {
107109 public static float kMinVolume = - 80.0f ; // The minimum volume is the level at which sends and effects can be bypassed
108- public static float kMaxEffect = 0.0f ;
110+ public static float kMaxEffect = 0.0f ;
109111 public static float kVolumeWarp = 1.7f ;
110112 public static string s_GroupEffectDisplaySeperator = "\\ " ; // Use backslash instead of forward slash to prevent OS menus from splitting path and creating submenus
111113
112114 public event ChangedExposedParameterHandler ChangedExposedParameter ;
113-
114115 public void OnChangedExposedParameter ( )
115116 {
116117 if ( ChangedExposedParameter != null )
@@ -130,7 +131,6 @@ public void ClearEventHandlers()
130131
131132 [ System . NonSerialized ]
132133 private Dictionary < GUID , AudioParameterPath > m_ExposedParamPathCache ;
133-
134134 private Dictionary < GUID , AudioParameterPath > exposedParamCache
135135 {
136136 get
@@ -221,48 +221,35 @@ public string ResolveExposedParameterPath(GUID parameter, bool getOnlyBasePath)
221221 List < AudioMixerGroupController > groups = GetAllAudioGroupsSlow ( ) ;
222222 foreach ( AudioMixerGroupController group in groups )
223223 {
224- if ( group . GetGUIDForVolume ( ) == parameter || group . GetGUIDForPitch ( ) == parameter )
224+ if ( group . GetGUIDForVolume ( ) == parameter ||
225+ group . GetGUIDForPitch ( ) == parameter ||
226+ group . GetGUIDForSend ( ) == parameter )
225227 {
226228 AudioGroupParameterPath newPath = new AudioGroupParameterPath ( group , parameter ) ;
227229 exposedParamCache [ parameter ] = newPath ;
228230 return newPath . ResolveStringPath ( getOnlyBasePath ) ;
229231 }
230-
231- for ( int i = 0 ; i < group . effects . Length ; i ++ )
232+ else
232233 {
233- AudioMixerEffectController effect = group . effects [ i ] ;
234- MixerParameterDefinition [ ] paramDefs = MixerEffectDefinitions . GetEffectParameters ( effect . effectName ) ;
235-
236- var found = false ;
237-
238- if ( parameter == effect . GetGUIDForMixLevel ( ) )
234+ for ( int i = 0 ; i < group . effects . Length ; i ++ )
239235 {
240- found = true ;
241- }
242- else
243- {
244- for ( var j = 0 ; j < paramDefs . Length ; j ++ )
245- {
246- var nextGuid = effect . GetGUIDForParameter ( paramDefs [ j ] . name ) ;
236+ AudioMixerEffectController effect = group . effects [ i ] ;
237+ MixerParameterDefinition [ ] paramDefs = MixerEffectDefinitions . GetEffectParameters ( effect . effectName ) ;
247238
248- if ( parameter == nextGuid )
239+ for ( int j = 0 ; j < paramDefs . Length ; j ++ )
240+ {
241+ GUID guid = effect . GetGUIDForParameter ( paramDefs [ j ] . name ) ;
242+ if ( guid == parameter )
249243 {
250- found = true ;
251- break ;
244+ AudioEffectParameterPath newPath = new AudioEffectParameterPath ( group , effect , parameter ) ;
245+ exposedParamCache [ parameter ] = newPath ;
246+ return newPath . ResolveStringPath ( getOnlyBasePath ) ;
252247 }
253248 }
254249 }
255-
256- if ( found )
257- {
258- var newPath = new AudioEffectParameterPath ( group , effect , parameter ) ;
259- exposedParamCache [ parameter ] = newPath ;
260- return newPath . ResolveStringPath ( getOnlyBasePath ) ;
261- }
262250 }
263251 }
264-
265- return "Error finding parameter path" ;
252+ return "Error finding Parameter path" ;
266253 }
267254
268255 public static AudioMixerController CreateMixerControllerAtPath ( string path )
@@ -342,7 +329,6 @@ private bool IsChildOf(AudioMixerGroupController child, List<AudioMixerGroupCont
342329 if ( groups . Contains ( child ) )
343330 return true ;
344331 }
345-
346332 return false ;
347333 }
348334
@@ -365,7 +351,6 @@ private void RemoveAncestorGroups(List<AudioMixerGroupController> groups)
365351 private void DestroyExposedParametersContainedInEffect ( AudioMixerEffectController effect )
366352 {
367353 Undo . RecordObject ( this , "Changed Exposed Parameters" ) ;
368-
369354 //Cleanup exposed parameters that were in the effect
370355 var exposedParams = exposedParameters ;
371356 foreach ( var param in exposedParams )
@@ -378,12 +363,11 @@ private void DestroyExposedParametersContainedInEffect(AudioMixerEffectControlle
378363 private void DestroyExposedParametersContainedInGroup ( AudioMixerGroupController group )
379364 {
380365 Undo . RecordObject ( this , "Remove Exposed Parameter" ) ;
381-
382366 //Clean up the exposed parameters that were in the group.
383367 var exposedParams = exposedParameters ;
384368 foreach ( var param in exposedParams )
385369 {
386- if ( group . GetGUIDForVolume ( ) == param . guid || group . GetGUIDForPitch ( ) == param . guid )
370+ if ( group . GetGUIDForVolume ( ) == param . guid || group . GetGUIDForPitch ( ) == param . guid || group . GetGUIDForSend ( ) == param . guid )
387371 RemoveExposedParameter ( param . guid ) ;
388372 }
389373 }
@@ -562,7 +546,6 @@ public AudioMixerGroupController FindParentGroup(AudioMixerGroupController node,
562546 if ( g != null )
563547 return g ;
564548 }
565-
566549 return null ;
567550 }
568551
@@ -618,6 +601,8 @@ private AudioMixerGroupController DuplicateGroupRecurse(AudioMixerGroupControlle
618601 s . SetValue ( targetGroup . GetGUIDForVolume ( ) , value ) ;
619602 if ( s . GetValue ( sourceGroup . GetGUIDForPitch ( ) , out value ) )
620603 s . SetValue ( targetGroup . GetGUIDForPitch ( ) , value ) ;
604+ if ( s . GetValue ( sourceGroup . GetGUIDForSend ( ) , out value ) )
605+ s . SetValue ( targetGroup . GetGUIDForSend ( ) , value ) ;
621606 }
622607
623608 AssetDatabase . AddObjectToAsset ( targetGroup , this ) ;
@@ -677,7 +662,6 @@ public void CopyEffectSettingsToAllSnapshots(AudioMixerGroupController group, in
677662 if ( snapshot . GetValue ( guid , out value ) )
678663 snaps [ n ] . SetValue ( guid , value ) ;
679664 }
680-
681665 foreach ( var p in paramDefs )
682666 {
683667 var guid = effect . GetGUIDForParameter ( p . name ) ;
@@ -766,7 +750,6 @@ public static bool MoveEffect(ref List<AudioMixerEffectController> sourceEffects
766750 if ( sourceIndex == targetIndex )
767751 return false ;
768752 }
769-
770753 if ( sourceIndex < 0 || sourceIndex >= sourceEffects . Count )
771754 return false ;
772755 if ( targetIndex < 0 || targetIndex > targetEffects . Count )
@@ -802,7 +785,6 @@ public class ConnectionNode
802785 public List < object > targets = new List < object > ( ) ;
803786 public AudioMixerGroupController group = null ;
804787 public AudioMixerEffectController effect = null ;
805-
806788 public string GetDisplayString ( )
807789 {
808790 string s = group . GetDisplayString ( ) ;
@@ -849,17 +831,13 @@ static private Dictionary<object, ConnectionNode> BuildTemporaryGraph(
849831 graph [ target ] . group = group ;
850832 graph [ target ] . effect = target ;
851833 }
852-
853834 if ( ! graph [ effect ] . targets . Contains ( target ) )
854835 graph [ effect ] . targets . Add ( target ) ;
855836 }
856-
857837 groupTail = effect ;
858838 }
859-
860839 graph [ group ] . groupTail = groupTail ;
861840 }
862-
863841 return graph ;
864842 }
865843
@@ -886,10 +864,8 @@ static private bool CheckForCycle(object curr, Dictionary<object, ConnectionNode
886864 identifiedLoop . Clear ( ) ;
887865 identifiedLoop . Add ( node ) ;
888866 }
889-
890867 return true ;
891868 }
892-
893869 node . visited = true ;
894870 foreach ( var s in node . targets )
895871 {
@@ -901,7 +877,6 @@ static private bool CheckForCycle(object curr, Dictionary<object, ConnectionNode
901877 return true ;
902878 }
903879 }
904-
905880 node . visited = false ;
906881 return false ;
907882 }
@@ -923,11 +898,9 @@ static public bool DoesTheTemporaryGraphHaveAnyCycles(List<AudioMixerGroupContro
923898 identifiedLoop . RemoveRange ( i , identifiedLoop . Count - i ) ;
924899 identifiedLoop . Reverse ( ) ;
925900 }
926-
927901 return true ;
928902 }
929903 }
930-
931904 return false ;
932905 }
933906
0 commit comments