5
5
using System . Collections . Generic ;
6
6
using UnityEngine ;
7
7
using UnityEngine . Audio ;
8
+ using UnityEditor ;
9
+ using UnityEditor . Audio ;
10
+ using System . IO ;
8
11
using System ;
9
12
using System . Linq ;
13
+
10
14
using Object = UnityEngine . Object ;
11
15
12
16
namespace UnityEditor . Audio
@@ -37,13 +41,18 @@ public override string ResolveStringPath(bool getOnlyBasePath)
37
41
{
38
42
return "Volume" + GetBasePath ( group . GetDisplayString ( ) , null ) ;
39
43
}
40
-
41
- if ( group . GetGUIDForPitch ( ) == parameter )
44
+ else if ( group . GetGUIDForPitch ( ) == parameter )
42
45
{
43
46
return "Pitch" + GetBasePath ( group . GetDisplayString ( ) , null ) ;
44
47
}
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
+ }
47
56
}
48
57
49
58
protected string GetBasePath ( string group , string effect )
@@ -73,29 +82,22 @@ public override string ResolveStringPath(bool getOnlyBasePath)
73
82
74
83
if ( effect . GetGUIDForMixLevel ( ) == parameter )
75
84
{
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 ) ;
84
86
}
85
-
86
- MixerParameterDefinition [ ] paramDefs = MixerEffectDefinitions . GetEffectParameters ( effect . effectName ) ;
87
-
88
- for ( int i = 0 ; i < paramDefs . Length ; i ++ )
87
+ else
89
88
{
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 ++ )
93
91
{
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
+ }
95
97
}
96
- }
97
98
98
- return "Error finding parameter path." ;
99
+ return "Error finding Parameter path." ;
100
+ }
99
101
}
100
102
}
101
103
@@ -105,12 +107,11 @@ public override string ResolveStringPath(bool getOnlyBasePath)
105
107
internal sealed partial class AudioMixerController : AudioMixer
106
108
{
107
109
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 ;
109
111
public static float kVolumeWarp = 1.7f ;
110
112
public static string s_GroupEffectDisplaySeperator = "\\ " ; // Use backslash instead of forward slash to prevent OS menus from splitting path and creating submenus
111
113
112
114
public event ChangedExposedParameterHandler ChangedExposedParameter ;
113
-
114
115
public void OnChangedExposedParameter ( )
115
116
{
116
117
if ( ChangedExposedParameter != null )
@@ -130,7 +131,6 @@ public void ClearEventHandlers()
130
131
131
132
[ System . NonSerialized ]
132
133
private Dictionary < GUID , AudioParameterPath > m_ExposedParamPathCache ;
133
-
134
134
private Dictionary < GUID , AudioParameterPath > exposedParamCache
135
135
{
136
136
get
@@ -221,48 +221,35 @@ public string ResolveExposedParameterPath(GUID parameter, bool getOnlyBasePath)
221
221
List < AudioMixerGroupController > groups = GetAllAudioGroupsSlow ( ) ;
222
222
foreach ( AudioMixerGroupController group in groups )
223
223
{
224
- if ( group . GetGUIDForVolume ( ) == parameter || group . GetGUIDForPitch ( ) == parameter )
224
+ if ( group . GetGUIDForVolume ( ) == parameter ||
225
+ group . GetGUIDForPitch ( ) == parameter ||
226
+ group . GetGUIDForSend ( ) == parameter )
225
227
{
226
228
AudioGroupParameterPath newPath = new AudioGroupParameterPath ( group , parameter ) ;
227
229
exposedParamCache [ parameter ] = newPath ;
228
230
return newPath . ResolveStringPath ( getOnlyBasePath ) ;
229
231
}
230
-
231
- for ( int i = 0 ; i < group . effects . Length ; i ++ )
232
+ else
232
233
{
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 ++ )
239
235
{
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 ) ;
247
238
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 )
249
243
{
250
- found = true ;
251
- break ;
244
+ AudioEffectParameterPath newPath = new AudioEffectParameterPath ( group , effect , parameter ) ;
245
+ exposedParamCache [ parameter ] = newPath ;
246
+ return newPath . ResolveStringPath ( getOnlyBasePath ) ;
252
247
}
253
248
}
254
249
}
255
-
256
- if ( found )
257
- {
258
- var newPath = new AudioEffectParameterPath ( group , effect , parameter ) ;
259
- exposedParamCache [ parameter ] = newPath ;
260
- return newPath . ResolveStringPath ( getOnlyBasePath ) ;
261
- }
262
250
}
263
251
}
264
-
265
- return "Error finding parameter path" ;
252
+ return "Error finding Parameter path" ;
266
253
}
267
254
268
255
public static AudioMixerController CreateMixerControllerAtPath ( string path )
@@ -342,7 +329,6 @@ private bool IsChildOf(AudioMixerGroupController child, List<AudioMixerGroupCont
342
329
if ( groups . Contains ( child ) )
343
330
return true ;
344
331
}
345
-
346
332
return false ;
347
333
}
348
334
@@ -365,7 +351,6 @@ private void RemoveAncestorGroups(List<AudioMixerGroupController> groups)
365
351
private void DestroyExposedParametersContainedInEffect ( AudioMixerEffectController effect )
366
352
{
367
353
Undo . RecordObject ( this , "Changed Exposed Parameters" ) ;
368
-
369
354
//Cleanup exposed parameters that were in the effect
370
355
var exposedParams = exposedParameters ;
371
356
foreach ( var param in exposedParams )
@@ -378,12 +363,11 @@ private void DestroyExposedParametersContainedInEffect(AudioMixerEffectControlle
378
363
private void DestroyExposedParametersContainedInGroup ( AudioMixerGroupController group )
379
364
{
380
365
Undo . RecordObject ( this , "Remove Exposed Parameter" ) ;
381
-
382
366
//Clean up the exposed parameters that were in the group.
383
367
var exposedParams = exposedParameters ;
384
368
foreach ( var param in exposedParams )
385
369
{
386
- if ( group . GetGUIDForVolume ( ) == param . guid || group . GetGUIDForPitch ( ) == param . guid )
370
+ if ( group . GetGUIDForVolume ( ) == param . guid || group . GetGUIDForPitch ( ) == param . guid || group . GetGUIDForSend ( ) == param . guid )
387
371
RemoveExposedParameter ( param . guid ) ;
388
372
}
389
373
}
@@ -562,7 +546,6 @@ public AudioMixerGroupController FindParentGroup(AudioMixerGroupController node,
562
546
if ( g != null )
563
547
return g ;
564
548
}
565
-
566
549
return null ;
567
550
}
568
551
@@ -618,6 +601,8 @@ private AudioMixerGroupController DuplicateGroupRecurse(AudioMixerGroupControlle
618
601
s . SetValue ( targetGroup . GetGUIDForVolume ( ) , value ) ;
619
602
if ( s . GetValue ( sourceGroup . GetGUIDForPitch ( ) , out value ) )
620
603
s . SetValue ( targetGroup . GetGUIDForPitch ( ) , value ) ;
604
+ if ( s . GetValue ( sourceGroup . GetGUIDForSend ( ) , out value ) )
605
+ s . SetValue ( targetGroup . GetGUIDForSend ( ) , value ) ;
621
606
}
622
607
623
608
AssetDatabase . AddObjectToAsset ( targetGroup , this ) ;
@@ -677,7 +662,6 @@ public void CopyEffectSettingsToAllSnapshots(AudioMixerGroupController group, in
677
662
if ( snapshot . GetValue ( guid , out value ) )
678
663
snaps [ n ] . SetValue ( guid , value ) ;
679
664
}
680
-
681
665
foreach ( var p in paramDefs )
682
666
{
683
667
var guid = effect . GetGUIDForParameter ( p . name ) ;
@@ -766,7 +750,6 @@ public static bool MoveEffect(ref List<AudioMixerEffectController> sourceEffects
766
750
if ( sourceIndex == targetIndex )
767
751
return false ;
768
752
}
769
-
770
753
if ( sourceIndex < 0 || sourceIndex >= sourceEffects . Count )
771
754
return false ;
772
755
if ( targetIndex < 0 || targetIndex > targetEffects . Count )
@@ -802,7 +785,6 @@ public class ConnectionNode
802
785
public List < object > targets = new List < object > ( ) ;
803
786
public AudioMixerGroupController group = null ;
804
787
public AudioMixerEffectController effect = null ;
805
-
806
788
public string GetDisplayString ( )
807
789
{
808
790
string s = group . GetDisplayString ( ) ;
@@ -849,17 +831,13 @@ static private Dictionary<object, ConnectionNode> BuildTemporaryGraph(
849
831
graph [ target ] . group = group ;
850
832
graph [ target ] . effect = target ;
851
833
}
852
-
853
834
if ( ! graph [ effect ] . targets . Contains ( target ) )
854
835
graph [ effect ] . targets . Add ( target ) ;
855
836
}
856
-
857
837
groupTail = effect ;
858
838
}
859
-
860
839
graph [ group ] . groupTail = groupTail ;
861
840
}
862
-
863
841
return graph ;
864
842
}
865
843
@@ -886,10 +864,8 @@ static private bool CheckForCycle(object curr, Dictionary<object, ConnectionNode
886
864
identifiedLoop . Clear ( ) ;
887
865
identifiedLoop . Add ( node ) ;
888
866
}
889
-
890
867
return true ;
891
868
}
892
-
893
869
node . visited = true ;
894
870
foreach ( var s in node . targets )
895
871
{
@@ -901,7 +877,6 @@ static private bool CheckForCycle(object curr, Dictionary<object, ConnectionNode
901
877
return true ;
902
878
}
903
879
}
904
-
905
880
node . visited = false ;
906
881
return false ;
907
882
}
@@ -923,11 +898,9 @@ static public bool DoesTheTemporaryGraphHaveAnyCycles(List<AudioMixerGroupContro
923
898
identifiedLoop . RemoveRange ( i , identifiedLoop . Count - i ) ;
924
899
identifiedLoop . Reverse ( ) ;
925
900
}
926
-
927
901
return true ;
928
902
}
929
903
}
930
-
931
904
return false ;
932
905
}
933
906
0 commit comments