Skip to content

Commit 020ee48

Browse files
author
Unity Technologies
committed
Unity 2018.3.14f1 C# reference source code
1 parent 38a478d commit 020ee48

File tree

19 files changed

+144
-120
lines changed

19 files changed

+144
-120
lines changed

Editor/Mono/EditorGUI.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
using Object = UnityEngine.Object;
1717
using Event = UnityEngine.Event;
1818
using UnityEditor.Build;
19-
using UnityEditor.StyleSheets;
2019
using UnityEngine.Internal;
2120
using UnityEngine.Rendering;
22-
using DescriptionAttribute = System.ComponentModel.DescriptionAttribute;
2321

2422
namespace UnityEditor
2523
{
@@ -3164,12 +3162,12 @@ internal struct EnumData
31643162

31653163
private static string EnumNameFromEnumField(FieldInfo field)
31663164
{
3167-
var description = field.GetCustomAttributes(typeof(DescriptionAttribute), false);
3165+
var description = field.GetCustomAttributes(typeof(InspectorNameAttribute), false);
31683166
if (description.Length > 0)
31693167
{
3170-
return ((DescriptionAttribute)description.First()).Description;
3168+
return ((InspectorNameAttribute)description.First()).displayName;
31713169
}
3172-
else if (field.IsDefined(typeof(ObsoleteAttribute), false))
3170+
if (field.IsDefined(typeof(ObsoleteAttribute), false))
31733171
{
31743172
return string.Format("{0} (Obsolete)", ObjectNames.NicifyVariableName(field.Name));
31753173
}

Editor/Mono/GUI/FlowLayout.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public override void SetHorizontal(float x, float width)
7575
if (i.rect.xMax - pulledOffset > x + width)
7676
{
7777
// TODO: When we move a line back, we should re-expand
78-
pulledOffset = i.rect.x - i.margin.left;
78+
pulledOffset = i.rect.x - i.marginLeft;
7979
m_Lines++;
8080
}
8181
i.SetHorizontal(i.rect.x - pulledOffset, i.rect.width);
@@ -114,8 +114,8 @@ public override void CalcHeight()
114114
int j = (int)i.rect.y;
115115
m_LineInfo[j].minSize = Mathf.Max(i.minHeight, m_LineInfo[j].minSize);
116116
m_LineInfo[j].maxSize = Mathf.Max(i.maxHeight, m_LineInfo[j].maxSize);
117-
m_LineInfo[j].topBorder = Mathf.Min(i.margin.top, m_LineInfo[j].topBorder);
118-
m_LineInfo[j].bottomBorder = Mathf.Min(i.margin.bottom, m_LineInfo[j].bottomBorder);
117+
m_LineInfo[j].topBorder = Mathf.Min(i.marginTop, m_LineInfo[j].topBorder);
118+
m_LineInfo[j].bottomBorder = Mathf.Min(i.marginBottom, m_LineInfo[j].bottomBorder);
119119
}
120120

121121
for (int i = 0; i < m_Lines; i++)
@@ -138,8 +138,8 @@ public override void CalcHeight()
138138
// Do the dance between children & parent for haggling over how many empty pixels to have
139139
float firstPadding, lastPadding;
140140

141-
margin.top = _topMarginMin;
142-
margin.bottom = _bottomMarginMin;
141+
m_MarginTop = _topMarginMin;
142+
m_MarginBottom = _bottomMarginMin;
143143
firstPadding = lastPadding = 0;
144144

145145
minHeight = Mathf.Max(minHeight, m_ChildMinHeight + firstPadding + lastPadding);
@@ -173,8 +173,8 @@ public override void SetVertical(float y, float height)
173173
y = 0;
174174

175175
float clientY, clientHeight;
176-
clientY = y - margin.top;
177-
clientHeight = y + margin.vertical;
176+
clientY = y - marginTop;
177+
clientHeight = y + marginVertical;
178178

179179
// Figure out how to distribute the elements between the different lines
180180
float heightToDistribute = clientHeight - spacing * (m_Lines - 1);
@@ -197,9 +197,9 @@ public override void SetVertical(float y, float height)
197197
{
198198
LineInfo li = m_LineInfo[(int)i.rect.y];
199199
if (i.stretchHeight != 0)
200-
i.SetVertical(li.start + i.margin.top, li.size - i.margin.vertical);
200+
i.SetVertical(li.start + i.marginTop, li.size - i.marginVertical);
201201
else
202-
i.SetVertical(li.start + i.margin.top, Mathf.Clamp(li.size - i.margin.vertical, i.minHeight, i.maxHeight));
202+
i.SetVertical(li.start + i.marginTop, Mathf.Clamp(li.size - i.marginVertical, i.minHeight, i.maxHeight));
203203
}
204204
}
205205
}

Editor/Mono/GUI/ListViewGUILayout.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ public override void CalcHeight()
148148

149149
base.CalcHeight();
150150

151-
margin.top = 0;
152-
margin.bottom = 0;
151+
m_MarginTop = 0;
152+
m_MarginBottom = 0;
153153

154154
if (minHeight == 0) // empty lv?
155155
{

Editor/Mono/GUI/ReorderableList.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class ReorderableList
3131
public delegate void ChangedCallbackDelegate(ReorderableList list);
3232
public delegate bool CanRemoveCallbackDelegate(ReorderableList list);
3333
public delegate bool CanAddCallbackDelegate(ReorderableList list);
34+
public delegate void DragCallbackDelegate(ReorderableList list);
3435

3536

3637
// draw callbacks
@@ -51,6 +52,7 @@ public class ReorderableList
5152
public AddCallbackDelegate onAddCallback;
5253
public AddDropdownCallbackDelegate onAddDropdownCallback;
5354
public RemoveCallbackDelegate onRemoveCallback;
55+
public DragCallbackDelegate onMouseDragCallback;
5456
public SelectCallbackDelegate onMouseUpCallback;
5557
public CanRemoveCallbackDelegate onCanRemoveCallback;
5658
public CanAddCallbackDelegate onCanAddCallback;
@@ -705,6 +707,9 @@ private void DoDraggingAndSelection(Rect listRect)
705707
// Set m_Dragging state on first MouseDrag event after we got hotcontrol (to prevent animating elements when deleting elements by context menu)
706708
m_Dragging = true;
707709

710+
if (onMouseUpCallback != null)
711+
onMouseDragCallback(this);
712+
708713
// if we are dragging, update the position
709714
UpdateDraggedY(listRect);
710715
evt.Use();

Editor/Mono/GUI/Splitter.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ public override void SetVertical(float y, float height)
296296
float topMar = padding.top, bottomMar = padding.bottom;
297297
if (entries.Count != 0)
298298
{
299-
topMar = Mathf.Max(topMar, ((GUILayoutEntry)entries[0]).margin.top);
300-
bottomMar = Mathf.Max(bottomMar, ((GUILayoutEntry)entries[entries.Count - 1]).margin.bottom);
299+
topMar = Mathf.Max(topMar, ((GUILayoutEntry)entries[0]).marginTop);
300+
bottomMar = Mathf.Max(bottomMar, ((GUILayoutEntry)entries[entries.Count - 1]).marginBottom);
301301
}
302302
y += topMar;
303303
height -= bottomMar + topMar;
@@ -334,9 +334,9 @@ public override void SetVertical(float y, float height)
334334
{
335335
foreach (GUILayoutEntry i in entries)
336336
{
337-
float topMar = Mathf.Max(i.margin.top, padding.top);
337+
float topMar = Mathf.Max(i.marginTop, padding.top);
338338
float thisY = y + topMar;
339-
float thisHeight = height - Mathf.Max(i.margin.bottom, padding.bottom) - topMar;
339+
float thisHeight = height - Mathf.Max(i.marginBottom, padding.bottom) - topMar;
340340

341341
if (i.stretchHeight != 0)
342342
i.SetVertical(thisY, thisHeight);
@@ -347,14 +347,14 @@ public override void SetVertical(float y, float height)
347347
else
348348
{
349349
// If not, the subelements' margins have already been propagated upwards to this group, so we can safely ignore them
350-
float thisY = y - margin.top;
351-
float thisHeight = height + margin.vertical;
350+
float thisY = y - marginTop;
351+
float thisHeight = height + marginVertical;
352352
foreach (GUILayoutEntry i in entries)
353353
{
354354
if (i.stretchHeight != 0)
355-
i.SetVertical(thisY + i.margin.top, thisHeight - i.margin.vertical);
355+
i.SetVertical(thisY + i.marginTop, thisHeight - i.marginVertical);
356356
else
357-
i.SetVertical(thisY + i.margin.top, Mathf.Clamp(thisHeight - i.margin.vertical, i.minHeight, i.maxHeight));
357+
i.SetVertical(thisY + i.marginTop, Mathf.Clamp(thisHeight - i.marginVertical, i.minHeight, i.maxHeight));
358358
}
359359
}
360360
}

Editor/Mono/Inspector/AudioManagerInspector.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@ private class Styles
2626
public static GUIContent AmbisonicDecoderPlugin = EditorGUIUtility.TrTextContent("Ambisonic Decoder Plugin", "Native audio plugin performing ambisonic-to-binaural filtering of sources.");
2727
public static GUIContent DisableAudio = EditorGUIUtility.TrTextContent("Disable Unity Audio", "Prevent allocating the output device in the runtime. Use this if you want to use other sound systems than the built-in one.");
2828
public static GUIContent VirtualizeEffects = EditorGUIUtility.TrTextContent("Virtualize Effects", "When enabled dynamically turn off effects and spatializers on AudioSources that are culled in order to save CPU.");
29+
30+
public static GUIContent DSPBufferSizeInfo = EditorGUIUtility.TrTextContent("The requested buffer size ({0}) has been overridden to {1} by the operating system");
2931
}
3032

3133
private SerializedProperty m_Volume;
3234
private SerializedProperty m_RolloffScale;
3335
private SerializedProperty m_DopplerFactor;
3436
private SerializedProperty m_DefaultSpeakerMode;
3537
private SerializedProperty m_SampleRate;
36-
private SerializedProperty m_DSPBufferSize;
38+
private SerializedProperty m_RequestedDSPBufferSize;
39+
private SerializedProperty m_ActualDSPBufferSize;
3740
private SerializedProperty m_VirtualVoiceCount;
3841
private SerializedProperty m_RealVoiceCount;
3942
private SerializedProperty m_SpatializerPlugin;
@@ -48,7 +51,8 @@ private void OnEnable()
4851
m_DopplerFactor = serializedObject.FindProperty("Doppler Factor");
4952
m_DefaultSpeakerMode = serializedObject.FindProperty("Default Speaker Mode");
5053
m_SampleRate = serializedObject.FindProperty("m_SampleRate");
51-
m_DSPBufferSize = serializedObject.FindProperty("m_DSPBufferSize");
54+
m_RequestedDSPBufferSize = serializedObject.FindProperty("m_RequestedDSPBufferSize");
55+
m_ActualDSPBufferSize = serializedObject.FindProperty("m_DSPBufferSize");
5256
m_VirtualVoiceCount = serializedObject.FindProperty("m_VirtualVoiceCount");
5357
m_RealVoiceCount = serializedObject.FindProperty("m_RealVoiceCount");
5458
m_SpatializerPlugin = serializedObject.FindProperty("m_SpatializerPlugin");
@@ -79,7 +83,13 @@ public override void OnInspectorGUI()
7983
EditorGUILayout.PropertyField(m_DopplerFactor, Styles.DopplerFactor);
8084
EditorGUILayout.PropertyField(m_DefaultSpeakerMode, Styles.DefaultSpeakerMode);
8185
EditorGUILayout.PropertyField(m_SampleRate, Styles.SampleRate);
82-
EditorGUILayout.PropertyField(m_DSPBufferSize, Styles.DSPBufferSize);
86+
EditorGUILayout.PropertyField(m_RequestedDSPBufferSize, Styles.DSPBufferSize);
87+
if (m_RequestedDSPBufferSize.intValue != m_ActualDSPBufferSize.intValue)
88+
EditorGUILayout.HelpBox(
89+
string.Format(Styles.DSPBufferSizeInfo.text,
90+
m_RequestedDSPBufferSize.intValue == 0 ? "default" : m_RequestedDSPBufferSize.intValue.ToString(),
91+
m_ActualDSPBufferSize.intValue),
92+
MessageType.Info);
8393
EditorGUILayout.PropertyField(m_VirtualVoiceCount, Styles.VirtualVoiceCount);
8494
EditorGUILayout.PropertyField(m_RealVoiceCount, Styles.RealVoiceCount);
8595

Editor/Mono/Inspector/ClothInspector.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,8 +1358,6 @@ void OnPreSceneGUI()
13581358
return;
13591359
}
13601360

1361-
// Disable Scene view tools, so we can use our own.
1362-
Tools.current = Tool.None;
13631361
if (state.ToolMode == (ToolMode)(-1))
13641362
state.ToolMode = ToolMode.Select;
13651363

Editor/Mono/Inspector/InspectorWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ private void DrawEditors(Editor[] editors)
10791079
bool showImportedObjectBarNext = false;
10801080
Rect importedObjectBarRect = new Rect();
10811081

1082-
if (editors.Length > 0 && editors[0].GetInstanceID() != m_LastInitialEditorInstanceID)
1082+
if ((editors.Length > 0 && editors[0].GetInstanceID() != m_LastInitialEditorInstanceID) || m_RemovedComponents == null)
10831083
OnTrackerRebuilt();
10841084
int prefabComponentIndex = -1;
10851085
for (int editorIndex = 0; editorIndex < editors.Length; editorIndex++)

Editor/Src/VR/Mono/PlayerSettingsEditorVR.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -553,16 +553,6 @@ private float GetVRDeviceElementHeight(BuildTargetGroup target, int index)
553553
return list.elementHeight + customOptionsHeight;
554554
}
555555

556-
private void SelectVRDeviceElement(BuildTargetGroup target, ReorderableList list)
557-
{
558-
string name = (string)m_VRDeviceActiveUI[target].list[list.index];
559-
VRCustomOptions customOptions;
560-
if (m_CustomOptions.TryGetValue(name, out customOptions))
561-
{
562-
customOptions.IsExpanded = false;
563-
}
564-
}
565-
566556
private bool GetVRDeviceElementIsInList(BuildTargetGroup target, string deviceName)
567557
{
568558
var enabledDevices = VREditor.GetVREnabledDevicesOnTargetGroup(target);
@@ -573,6 +563,16 @@ private bool GetVRDeviceElementIsInList(BuildTargetGroup target, string deviceNa
573563
return false;
574564
}
575565

566+
private void DragVRDeviceElement(BuildTargetGroup target, ReorderableList list)
567+
{
568+
string name = (string)m_VRDeviceActiveUI[target].list[list.index];
569+
VRCustomOptions customOptions;
570+
if (m_CustomOptions.TryGetValue(name, out customOptions))
571+
{
572+
customOptions.IsExpanded = false;
573+
}
574+
}
575+
576576
private void VRDevicesGUIOneBuildTarget(BuildTargetGroup targetGroup)
577577
{
578578
// create reorderable list for this target if needed
@@ -585,7 +585,7 @@ private void VRDevicesGUIOneBuildTarget(BuildTargetGroup targetGroup)
585585
rlist.drawElementCallback = (rect, index, isActive, isFocused) => DrawVRDeviceElement(targetGroup, rect, index, isActive, isFocused);
586586
rlist.drawHeaderCallback = (rect) => GUI.Label(rect, Styles.listHeader, EditorStyles.label);
587587
rlist.elementHeightCallback = (index) => GetVRDeviceElementHeight(targetGroup, index);
588-
rlist.onSelectCallback = (list) => SelectVRDeviceElement(targetGroup, list);
588+
rlist.onMouseDragCallback = (list) => DragVRDeviceElement(targetGroup, list);
589589
m_VRDeviceActiveUI.Add(targetGroup, rlist);
590590
}
591591

Modules/AssetPipelineEditor/Public/ModelImporting/ModelImporter.bindings.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Runtime.InteropServices;
77
using UnityEngine;
88
using UnityEngine.Bindings;
9-
using DescriptionAttribute = System.ComponentModel.DescriptionAttribute;
109
using Object = UnityEngine.Object;
1110
using UsedByNativeCodeAttribute = UnityEngine.Scripting.UsedByNativeCodeAttribute;
1211

@@ -236,7 +235,7 @@ public enum ModelImporterNormals
236235
[NativeType(Header = "Modules/AssetPipelineEditor/Public/ModelImporting/ImportMesh.h")]
237236
public enum ModelImporterNormalCalculationMode
238237
{
239-
[Description("Unweighted (Legacy)")]
238+
[InspectorName("Unweighted (Legacy)")]
240239
Unweighted_Legacy,
241240

242241
Unweighted,
@@ -262,7 +261,7 @@ public enum ModelImporterTangents
262261
CalculateLegacy = 1,
263262

264263
CalculateLegacyWithSplitTangents = 4,
265-
[Description("Calculate Mikktspace")]
264+
[InspectorName("Calculate Mikktspace")]
266265
CalculateMikk = 3,
267266

268267
None = 2,
@@ -279,9 +278,9 @@ public enum ModelImporterMeshCompression
279278
public enum ModelImporterIndexFormat
280279
{
281280
Auto = 0,
282-
[Description("16 bits")]
281+
[InspectorName("16 bits")]
283282
UInt16 = 1,
284-
[Description("32 bits")]
283+
[InspectorName("32 bits")]
285284
UInt32 = 2,
286285
}
287286

0 commit comments

Comments
 (0)