Skip to content

Commit ce62a54

Browse files
author
Unity Technologies
committed
Unity 2020.2.0b1 C# reference source code
1 parent 11e25ce commit ce62a54

File tree

45 files changed

+318
-823
lines changed

Some content is hidden

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

45 files changed

+318
-823
lines changed

Editor/Mono/Animation/AnimationWindow/AnimationWindowHierarchyGUI.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ internal class AnimationWindowHierarchyGUI : TreeViewGUI
4040
public const float k_AddCurveButtonNodeHeight = 40f;
4141
public const float k_RowBackgroundColorBrightness = 0.28f;
4242
private const float k_SelectedPhantomCurveColorMultiplier = 1.4f;
43+
private const float k_CurveColorIndicatorIconSize = 11;
4344

4445
private readonly static Color k_KeyColorInDopesheetMode = new Color(0.7f, 0.7f, 0.7f, 1);
4546
private readonly static Color k_KeyColorForNonCurves = new Color(0.7f, 0.7f, 0.7f, 0.5f);
@@ -485,9 +486,8 @@ private void DoCurveColorIndicator(Rect rect, AnimationWindowHierarchyNode node)
485486
}
486487
}
487488
}
488-
489489
Texture icon = hasKey ? CurveUtility.GetIconKey() : CurveUtility.GetIconCurve();
490-
rect = new Rect(rect.xMax - k_RowRightOffset - (icon.width / 2) - 5, rect.yMin + k_ColorIndicatorTopMargin + (rect.height - EditorGUIUtility.singleLineHeight) / 2, icon.width, icon.height);
490+
rect = new Rect(rect.xMax - k_RowRightOffset - (k_CurveColorIndicatorIconSize / 2) - 5, rect.yMin + k_ColorIndicatorTopMargin + (rect.height - EditorGUIUtility.singleLineHeight) / 2, k_CurveColorIndicatorIconSize, k_CurveColorIndicatorIconSize);
491491
GUI.DrawTexture(rect, icon, ScaleMode.ScaleToFit, true, 1);
492492

493493
GUI.color = originalColor;

Editor/Mono/Animation/AnimationWindow/CurveEditor.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,6 +1794,9 @@ float SnapValue(float v)
17941794

17951795
new internal static class Styles
17961796
{
1797+
public const float pointIconCenterOffsetX = 7;
1798+
public const float pointIconCenterOffsetY = 8;
1799+
public const float pointIconSize = 16;
17971800
public static Texture2D pointIcon = EditorGUIUtility.LoadIcon("curvekeyframe");
17981801
public static Texture2D pointIconWeighted = EditorGUIUtility.LoadIcon("curvekeyframeweighted");
17991802
public static Texture2D pointIconSelected = EditorGUIUtility.LoadIcon("curvekeyframeselected");
@@ -3687,7 +3690,7 @@ void DrawPoint(Vector2 viewPos, CurveWrapper.SelectionMode selected, MouseCursor
36873690
{
36883691
// Important to take floor of positions of GUI stuff to get pixel correct alignment of
36893692
// stuff drawn with both GUI and Handles/GL. Otherwise things are off by one pixel half the time.
3690-
var rect = new Rect(Mathf.Floor(viewPos.x) - 4, Mathf.Floor(viewPos.y) - 4, Styles.pointIcon.width, Styles.pointIcon.height);
3693+
var rect = new Rect(Mathf.Floor(viewPos.x) - Styles.pointIconCenterOffsetX, Mathf.Floor(viewPos.y) - Styles.pointIconCenterOffsetY, Styles.pointIconSize, Styles.pointIconSize);
36913694

36923695
if (selected == CurveWrapper.SelectionMode.None)
36933696
{
@@ -3713,7 +3716,7 @@ void DrawTangentPoint(Vector2 viewPos, bool weighted)
37133716
{
37143717
// Important to take floor of positions of GUI stuff to get pixel correct alignment of
37153718
// stuff drawn with both GUI and Handles/GL. Otherwise things are off by one pixel half the time.
3716-
var rect = new Rect(Mathf.Floor(viewPos.x) - 4, Mathf.Floor(viewPos.y) - 4, Styles.pointIcon.width, Styles.pointIcon.height);
3719+
var rect = new Rect(Mathf.Floor(viewPos.x) - Styles.pointIconCenterOffsetX, Mathf.Floor(viewPos.y) - Styles.pointIconCenterOffsetY, Styles.pointIconSize, Styles.pointIconSize);
37173720

37183721
if (weighted)
37193722
{

Editor/Mono/Animation/AnimationWindow/Deprecated/AnimationEventTimeline.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ internal static class Styles
2727
private AnimationEvent[] m_EventsAtMouseDown;
2828
[System.NonSerialized]
2929
private float[] m_EventTimes;
30+
private static readonly Vector2 k_EventMarkerSize = new Vector2(16, 16);
3031

3132
private bool m_DirtyTooltip = false;
3233
private int m_HoverEvent = -1;
@@ -199,15 +200,15 @@ public void EventLineGUI(Rect rect, AnimationWindowState state)
199200
int sharedOffset = 0;
200201
if (shared > 1)
201202
{
202-
float spread = Mathf.Min((shared - 1) * (eventMarker.width - 1), (int)(state.FrameDeltaToPixel(rect) - eventMarker.width * 2));
203-
sharedOffset = Mathf.FloorToInt(Mathf.Max(0, spread - (eventMarker.width - 1) * (sharedLeft)));
203+
float spread = Mathf.Min((shared - 1) * (k_EventMarkerSize.x - 1), (int)(state.FrameDeltaToPixel(rect) - k_EventMarkerSize.x * 2));
204+
sharedOffset = Mathf.FloorToInt(Mathf.Max(0, spread - (k_EventMarkerSize.x - 1) * (sharedLeft)));
204205
}
205206

206207
Rect r = new Rect(
207-
keypos + sharedOffset - eventMarker.width / 2,
208+
keypos + sharedOffset - k_EventMarkerSize.x / 2,
208209
(rect.height - 10) * (float)(sharedLeft - shared + 1) / Mathf.Max(1, shared - 1),
209-
eventMarker.width,
210-
eventMarker.height);
210+
k_EventMarkerSize.x,
211+
k_EventMarkerSize.y);
211212

212213
hitRects[i] = r;
213214
drawRects[i] = r;

Editor/Mono/Animation/AnimationWindow/DopeSheetEditor.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ internal class DopeSheetEditor : TimeArea, CurveUpdater
2323
// Pptr keyframe preview also needs 1px offset so it sits more tightly in the grid
2424
private const float k_PptrKeyframeOffset = -1;
2525

26+
private static readonly Vector2 k_ControlPointSize = new Vector2(16, 16);
27+
2628
const int kLabelMarginHorizontal = 8;
2729
const int kLabelMarginVertical = 2;
2830

@@ -148,7 +150,7 @@ public void AddUnselectedKey(DrawElement element)
148150
else
149151
{
150152
Rect rect = element.position;
151-
rect.size = new Vector2(m_DefaultDopeKeyIcon.width, m_DefaultDopeKeyIcon.height);
153+
rect.size = k_ControlPointSize;
152154
m_UnselectedKeysRenderer.AddPoint(rect, element.color);
153155
}
154156
}
@@ -164,7 +166,7 @@ public void AddSelectedKey(DrawElement element)
164166
else
165167
{
166168
Rect rect = element.position;
167-
rect.size = new Vector2(m_DefaultDopeKeyIcon.width, m_DefaultDopeKeyIcon.height);
169+
rect.size = k_ControlPointSize;
168170
m_SelectedKeysRenderer.AddPoint(rect, element.color);
169171
}
170172
}
@@ -180,7 +182,7 @@ public void AddDragDropKey(DrawElement element)
180182
else
181183
{
182184
Rect rect = element.position;
183-
rect.size = new Vector2(m_DefaultDopeKeyIcon.width, m_DefaultDopeKeyIcon.height);
185+
rect.size = k_ControlPointSize;
184186
m_DragDropKeysRenderer.AddPoint(rect, element.color);
185187
}
186188
}

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public override DragAndDropVisualMode DoDrag(TreeViewItem parentNode, TreeViewIt
6565

6666
m_owner.Controller.ReparentSelection(parentGroup, insertionIndex, draggedGroups);
6767
m_owner.ReloadTree();
68+
m_owner.Controller.OnSubAssetChanged();
6869
m_TreeView.SetSelection(draggedIDs.ToArray(), true); // Ensure dropped item(s) are selected and revealed (fixes selection if click dragging a single item that is not selected when drag was started)
6970
}
7071
return validDrag ? DragAndDropVisualMode.Move : DragAndDropVisualMode.Rejected;
@@ -336,10 +337,7 @@ public void ReloadTree()
336337
{
337338
m_AudioGroupTree.ReloadData();
338339
if (m_Controller != null)
339-
{
340340
m_Controller.SanitizeGroupViews();
341-
m_Controller.OnSubAssetChanged();
342-
}
343341
}
344342

345343
public void AddChildGroupPopupCallback(object obj)
@@ -377,6 +375,7 @@ public void AddAudioMixerGroup(AudioMixerGroupController parent)
377375
m_Controller.OnUnitySelectionChanged();
378376
m_AudioGroupTree.SetSelection(new int[] { newGroup.GetInstanceID() }, true);
379377
ReloadTree();
378+
m_Controller.OnSubAssetChanged();
380379
m_AudioGroupTree.BeginNameEditing(0f);
381380
}
382381

@@ -402,6 +401,7 @@ public void DeleteGroups(List<AudioMixerGroupController> groups, bool recordUndo
402401

403402
m_Controller.DeleteGroups(groups.ToArray());
404403
ReloadTree();
404+
m_Controller.OnSubAssetChanged();
405405
}
406406

407407
public void DuplicateGroups(List<AudioMixerGroupController> groups, bool recordUndo)
@@ -416,6 +416,7 @@ public void DuplicateGroups(List<AudioMixerGroupController> groups, bool recordU
416416
if (duplicatedRoots.Count > 0)
417417
{
418418
ReloadTree();
419+
m_Controller.OnSubAssetChanged();
419420
var instanceIDs = duplicatedRoots.Select(audioMixerGroup => audioMixerGroup.GetInstanceID()).ToArray();
420421
m_AudioGroupTree.SetSelection(instanceIDs, false);
421422
m_AudioGroupTree.Frame(instanceIDs[instanceIDs.Length - 1], true, false);
@@ -678,6 +679,8 @@ public void EndRenaming()
678679
public void OnUndoRedoPerformed()
679680
{
680681
ReloadTree();
682+
if (m_Controller != null)
683+
m_Controller.OnSubAssetChanged();
681684
}
682685
}
683686
}

Editor/Mono/BuildPipeline/AssemblyStripper.cs

Lines changed: 16 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ private static string UnityLinkerPath
5050
}
5151
}
5252

53-
private static string GetModuleWhitelist(string module, string moduleStrippingInformationFolder)
54-
{
55-
return Paths.Combine(moduleStrippingInformationFolder, module + ".xml");
56-
}
57-
5853
static IEnumerable<string> SanitizeLinkXmlFilePaths(List<string> linkXmlFilePaths, UnityLinkerRunInformation runInformation)
5954
{
6055
foreach (var linkXmlFilePath in linkXmlFilePaths)
@@ -89,11 +84,6 @@ private static bool StripAssembliesTo(string outputFolder, out string output, ou
8984
$"-out={CommandLineFormatter.PrepareFileName(outputFolder)}",
9085
};
9186

92-
if (!UseUnityLinkerEngineModuleStripping)
93-
{
94-
args.Add($"-x={CommandLineFormatter.PrepareFileName(GetModuleWhitelist("Core", runInformation.platformProvider.moduleStrippingInformationFolder))}");
95-
}
96-
9787
args.AddRange(linkXmlFiles.Select(path => $"-x={CommandLineFormatter.PrepareFileName(path)}"));
9888
args.AddRange(runInformation.SearchDirectories.Select(d => $"-d={CommandLineFormatter.PrepareFileName(d)}"));
9989
args.AddRange(assemblies.Select(assembly => $"--include-unity-root-assembly={CommandLineFormatter.PrepareFileName(GetFullPath(assembly))}"));
@@ -128,11 +118,6 @@ private static bool StripAssembliesTo(string outputFolder, out string output, ou
128118
args.Add($"--architecture={architecture}");
129119
}
130120

131-
if (!UseUnityLinkerEngineModuleStripping)
132-
{
133-
args.Add("--disable-engine-module-support");
134-
}
135-
136121
if (runInformation.performEngineStripping)
137122
{
138123
args.Add("--enable-engine-module-stripping");
@@ -234,25 +219,6 @@ internal static IEnumerable<string> GetUserBlacklistFiles()
234219
return Directory.GetFiles("Assets", "link.xml", SearchOption.AllDirectories).Select(s => Path.Combine(Directory.GetCurrentDirectory(), s));
235220
}
236221

237-
private static bool AddWhiteListsForModules(IEnumerable<string> nativeModules, List<string> blacklists, string moduleStrippingInformationFolder)
238-
{
239-
bool result = false;
240-
foreach (var module in nativeModules)
241-
{
242-
var moduleWhitelist = GetModuleWhitelist(module, moduleStrippingInformationFolder);
243-
244-
if (File.Exists(moduleWhitelist))
245-
{
246-
if (!blacklists.Contains(moduleWhitelist))
247-
{
248-
blacklists.Add(moduleWhitelist);
249-
result = true;
250-
}
251-
}
252-
}
253-
return result;
254-
}
255-
256222
private static void RunAssemblyStripper(UnityLinkerRunInformation runInformation)
257223
{
258224
string output;
@@ -286,54 +252,29 @@ private static void RunAssemblyStripper(UnityLinkerRunInformation runInformation
286252

287253
WriteEditorData(runInformation);
288254

289-
if (!runInformation.performEngineStripping && !UseUnityLinkerEngineModuleStripping)
290-
{
291-
// if we don't do stripping, add all modules blacklists.
292-
linkXmlFiles.AddRange(runInformation.GetModuleBlacklistFiles());
293-
}
294-
295255
var tempStripPath = GetFullPath(Path.Combine(managedAssemblyFolderPath, "tempStrip"));
296256

297257
ProcessBuildPipelineOnBeforeRun(runInformation);
298258

299-
bool addedMoreBlacklists;
300-
do
301-
{
302-
addedMoreBlacklists = false;
303-
304-
if (EditorUtility.DisplayCancelableProgressBar("Building Player", "Stripping assemblies", 0.0f))
305-
throw new OperationCanceledException();
306-
307-
if (!StripAssembliesTo(
308-
tempStripPath,
309-
out output,
310-
out error,
311-
SanitizeLinkXmlFilePaths(linkXmlFiles, runInformation),
312-
runInformation))
313-
throw new Exception("Error in stripping assemblies: " + runInformation.AssembliesToProcess() + ", " + error);
314-
315-
if (runInformation.engineStrippingSupported)
316-
{
317-
var icallSummaryPath = Path.Combine(managedAssemblyFolderPath, "ICallSummary.txt");
318-
GenerateInternalCallSummaryFile(icallSummaryPath, managedAssemblyFolderPath, tempStripPath);
319-
320-
if (runInformation.performEngineStripping && !UseUnityLinkerEngineModuleStripping)
321-
{
322-
// Find which modules we must include in the build based on Assemblies
323-
HashSet<UnityType> nativeClasses;
324-
HashSet<string> nativeModules;
325-
CodeStrippingUtils.GenerateDependencies(tempStripPath, icallSummaryPath, rcr, runInformation.performEngineStripping, out nativeClasses, out nativeModules, runInformation.il2CppPlatformProvider);
326-
// Add module-specific blacklists.
327-
addedMoreBlacklists = AddWhiteListsForModules(nativeModules, linkXmlFiles, runInformation.platformProvider.moduleStrippingInformationFolder);
328-
}
329-
}
259+
if (EditorUtility.DisplayCancelableProgressBar("Building Player", "Stripping assemblies", 0.0f))
260+
throw new OperationCanceledException();
330261

331-
if (runInformation.performEngineStripping && UseUnityLinkerEngineModuleStripping)
332-
UpdateBuildReport(ReadLinkerToEditorData(tempStripPath), runInformation);
262+
if (!StripAssembliesTo(
263+
tempStripPath,
264+
out output,
265+
out error,
266+
SanitizeLinkXmlFilePaths(linkXmlFiles, runInformation),
267+
runInformation))
268+
throw new Exception("Error in stripping assemblies: " + runInformation.AssembliesToProcess() + ", " + error);
333269

334-
// If we had to add more whitelists, we need to run AssemblyStripper again with the added whitelists.
270+
if (runInformation.engineStrippingSupported)
271+
{
272+
var icallSummaryPath = Path.Combine(managedAssemblyFolderPath, "ICallSummary.txt");
273+
GenerateInternalCallSummaryFile(icallSummaryPath, managedAssemblyFolderPath, tempStripPath);
335274
}
336-
while (addedMoreBlacklists && !UseUnityLinkerEngineModuleStripping);
275+
276+
if (runInformation.performEngineStripping)
277+
UpdateBuildReport(ReadLinkerToEditorData(tempStripPath), runInformation);
337278

338279
// keep unstripped files for debugging purposes
339280
var tempUnstrippedPath = GetFullPath(Path.Combine(managedAssemblyFolderPath, "tempUnstripped"));
@@ -363,11 +304,6 @@ private static void RunAssemblyStripper(UnityLinkerRunInformation runInformation
363304
ProcessBuildPipelineOnAfterRun(runInformation);
364305
}
365306

366-
public static bool UseUnityLinkerEngineModuleStripping
367-
{
368-
get { return string.IsNullOrEmpty(Environment.GetEnvironmentVariable("UNITYLINKER_DISABLE_EMS")); }
369-
}
370-
371307
private static string WriteTypesInScenesBlacklist(string managedAssemblyDirectory, RuntimeClassRegistry rcr)
372308
{
373309
var items = rcr.GetAllManagedTypesInScenes();

0 commit comments

Comments
 (0)