Skip to content

Commit cdbef0c

Browse files
author
Unity Technologies
committed
Unity 2021.2.0a21 C# reference source code
1 parent e352b7c commit cdbef0c

File tree

54 files changed

+1033
-374
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1033
-374
lines changed

Editor/Mono/Animation/AnimationWindow/AnimationWindowCurve.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ public int CompareTo(AnimationWindowCurve obj)
112112
// We want to sort position before rotation
113113
if (sameTransformComponent)
114114
{
115-
string propertyGroupA = AnimationWindowUtility.GetNicePropertyGroupDisplayName(typeof(Transform), AnimationWindowUtility.GetPropertyGroupName(propertyName));
116-
string propertyGroupB = AnimationWindowUtility.GetNicePropertyGroupDisplayName(typeof(Transform), AnimationWindowUtility.GetPropertyGroupName(obj.propertyName));
115+
string propertyGroupA = AnimationWindowUtility.GetPropertyGroupName(propertyName);
116+
string propertyGroupB = AnimationWindowUtility.GetPropertyGroupName(obj.propertyName);
117117

118-
if (propertyGroupA.Contains("Position") && propertyGroupB.Contains("Rotation"))
118+
if (propertyGroupA.Equals("m_LocalPosition") && (propertyGroupB.Equals("m_LocalRotation") || propertyGroupB.StartsWith("localEulerAngles")))
119119
return -1;
120-
if (propertyGroupA.Contains("Rotation") && propertyGroupB.Contains("Position"))
120+
if ((propertyGroupA.Equals("m_LocalRotation") || propertyGroupA.StartsWith("localEulerAngles")) && propertyGroupB.Equals("m_LocalPosition"))
121121
return 1;
122122
}
123123
// Transform component should always come first.

Editor/Mono/Animation/AnimationWindow/AnimationWindowUtility.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -729,16 +729,21 @@ public static void RenameCurvePath(AnimationWindowCurve curve, EditorCurveBindin
729729
}
730730
}
731731

732+
private static readonly string k_PositionDisplayName = L10n.Tr("Position");
733+
private static readonly string k_ScaleDisplayName = L10n.Tr("Scale");
734+
private static readonly string k_RotationDisplayName = L10n.Tr("Rotation");
735+
private static readonly string k_MaterialReferenceDisplayName = L10n.Tr("Material Reference");
736+
732737
// Takes raw animation curve propertyname and makes it pretty
733738
public static string GetPropertyDisplayName(string propertyName)
734739
{
735-
propertyName = propertyName.Replace("m_LocalPosition", L10n.Tr("Position"));
736-
propertyName = propertyName.Replace("m_LocalScale", L10n.Tr("Scale"));
737-
propertyName = propertyName.Replace("m_LocalRotation", L10n.Tr("Rotation"));
738-
propertyName = propertyName.Replace("localEulerAnglesBaked", L10n.Tr("Rotation"));
739-
propertyName = propertyName.Replace("localEulerAnglesRaw", L10n.Tr("Rotation"));
740-
propertyName = propertyName.Replace("localEulerAngles", L10n.Tr("Rotation"));
741-
propertyName = propertyName.Replace("m_Materials.Array.data", L10n.Tr("Material Reference"));
740+
propertyName = propertyName.Replace("m_LocalPosition", k_PositionDisplayName);
741+
propertyName = propertyName.Replace("m_LocalScale", k_ScaleDisplayName);
742+
propertyName = propertyName.Replace("m_LocalRotation", k_RotationDisplayName);
743+
propertyName = propertyName.Replace("localEulerAnglesBaked", k_RotationDisplayName);
744+
propertyName = propertyName.Replace("localEulerAnglesRaw", k_RotationDisplayName);
745+
propertyName = propertyName.Replace("localEulerAngles", k_RotationDisplayName);
746+
propertyName = propertyName.Replace("m_Materials.Array.data", k_MaterialReferenceDisplayName);
742747

743748
propertyName = ObjectNames.NicifyVariableName(propertyName);
744749
propertyName = propertyName.Replace("m_", "");

Editor/Mono/Audio/Mixer/Bindings/AudioMixerController.cs

Lines changed: 43 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
using System.Collections.Generic;
66
using UnityEngine;
77
using UnityEngine.Audio;
8+
using UnityEditor;
9+
using UnityEditor.Audio;
10+
using System.IO;
811
using System;
912
using System.Linq;
13+
1014
using Object = UnityEngine.Object;
1115

1216
namespace 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

Editor/Mono/Audio/Mixer/Bindings/AudioMixerGroup.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
44

55
using UnityEngine;
6+
using UnityEditor;
7+
using UnityEditor.Audio;
8+
using System.IO;
69
using System.Collections.Generic;
710
using System;
811

@@ -57,17 +60,6 @@ public override string ToString()
5760
{
5861
return name;
5962
}
60-
61-
public static Dictionary<AudioMixerEffectController, AudioMixerGroupController> GetEffectMapSlow(List<AudioMixerGroupController> allGroups)
62-
{
63-
var effectMap = new Dictionary<AudioMixerEffectController, AudioMixerGroupController>();
64-
65-
foreach (var g in allGroups)
66-
foreach (var e in g.effects)
67-
effectMap[e] = g;
68-
69-
return effectMap;
70-
}
7163
}
7264

7365
internal class MixerGroupControllerCompareByName : IComparer<AudioMixerGroupController>

Editor/Mono/Audio/Mixer/GUI/AudioMixerChannelStripView.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ internal class AudioMixerChannelStripView
1818
[Serializable]
1919
public class State
2020
{
21-
public int m_LastClickedInstanceID = 0;
2221
public Vector2 m_ScrollPos = new Vector2(0, 0);
2322
}
2423

@@ -941,7 +940,7 @@ void GroupClicked(AudioMixerGroupController clickedGroup, ChannelStripParams p,
941940
foreach (var group in m_Controller.CachedSelection)
942941
selectedIDs.Add(group.GetInstanceID());
943942

944-
int lastClickedID = m_State.m_LastClickedInstanceID;
943+
int lastClickedID = selectedIDs.Count > 0 ? selectedIDs.Last() : 0;
945944
bool allowMultiselection = true;
946945
bool keepMultiSelection = Event.current.shift || clickedControlInGroup;
947946
bool useShiftAsActionKey = false;

0 commit comments

Comments
 (0)