Skip to content

Commit eea3fd5

Browse files
author
Unity Technologies
committed
Unity 2019.2.0b1 C# reference source code
1 parent 72264a6 commit eea3fd5

45 files changed

Lines changed: 331 additions & 162 deletions

Some content is hidden

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

Editor/Mono/Annotation/SceneViewCameraWindow.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@ public static void Init()
3030
readonly SceneView m_SceneView;
3131

3232
GUIContent m_CameraSpeedSliderContent;
33+
GUIContent m_AccelerationEnabled;
3334
GUIContent m_CameraSpeedMin;
3435
GUIContent m_CameraSpeedMax;
3536
GUIContent m_FieldOfView;
3637
GUIContent m_DynamicClip;
3738
GUIContent m_OcclusionCulling;
3839
GUIContent m_EasingEnabled;
39-
GUIContent m_EasingDuration;
4040

4141
const int kFieldCount = 12;
4242
const int kWindowWidth = 290;
4343
const int kWindowHeight = ((int)EditorGUI.kSingleLineHeight) * kFieldCount + kFrameWidth * 2;
44-
const int kFrameWidth = 10;
44+
const int kFrameWidth = 11;
4545
const float kPrefixLabelWidth = 120f;
4646
const float kMinSpeedLabelWidth = 25f;
4747
const float kMaxSpeedLabelWidth = 29f;
@@ -61,13 +61,13 @@ public SceneViewCameraWindow(SceneView sceneView)
6161
m_SceneView = sceneView;
6262

6363
m_CameraSpeedSliderContent = EditorGUIUtility.TrTextContent("Camera Speed", "The current speed of the camera in the Scene view.");
64+
m_AccelerationEnabled = EditorGUIUtility.TrTextContent("Camera Acceleration", "Check this to enable acceleration when moving the camera. When enabled, camera speed is evaluated as a modifier. With acceleration disabled, the camera is accelerated to the Camera Speed.");
6465
m_CameraSpeedMin = EditorGUIUtility.TrTextContent("Min", "The minimum speed of the camera in the Scene view. Valid values are between [0.01, 98].");
6566
m_CameraSpeedMax = EditorGUIUtility.TrTextContent("Max", "The maximum speed of the camera in the Scene view. Valid values are between [0.02, 99].");
6667
m_FieldOfView = EditorGUIUtility.TrTextContent("Field of View", "The height of the camera's view angle. Measured in degrees vertically, or along the local Y axis.");
6768
m_DynamicClip = EditorGUIUtility.TrTextContent("Dynamic Clipping", "Check this to enable camera's near and far clipping planes to be calculated relative to the viewport size of the Scene.");
6869
m_OcclusionCulling = EditorGUIUtility.TrTextContent("Occlusion Culling", "Check this to enable occlusion culling in the Scene view. Occlusion culling disables rendering of objects when they\'re not currently seen by the camera because they\'re hidden (occluded) by other objects.");
6970
m_EasingEnabled = EditorGUIUtility.TrTextContent("Camera Easing", "Check this to enable camera movement easing. This makes the camera ease in when it starts moving and ease out when it stops.");
70-
m_EasingDuration = EditorGUIUtility.TrTextContent("Duration", "How long it takes for the speed of the camera to accelerate to its initial full speed. Measured in seconds.");
7171
}
7272

7373
public override void OnGUI(Rect rect)
@@ -133,12 +133,7 @@ private void Draw(Rect rect)
133133

134134
settings.easingEnabled = EditorGUILayout.Toggle(m_EasingEnabled, settings.easingEnabled);
135135

136-
using (new EditorGUI.DisabledScope(!settings.easingEnabled))
137-
{
138-
EditorGUI.indentLevel += 1;
139-
settings.easingDuration = EditorGUILayout.Slider(m_EasingDuration, settings.easingDuration, .1f, 2f);
140-
EditorGUI.indentLevel -= 1;
141-
}
136+
settings.accelerationEnabled = EditorGUILayout.Toggle(m_AccelerationEnabled, settings.accelerationEnabled);
142137

143138
settings.speed = EditorGUILayout.Slider(m_CameraSpeedSliderContent, settings.speed, settings.speedMin, settings.speedMax);
144139

Editor/Mono/AssemblyInfo/AssemblyInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@
9999
[assembly: InternalsVisibleTo("Unity.InternalAPIEditorBridgeDev.005")]
100100
[assembly: InternalsVisibleTo("Unity.XR.Remoting.Editor")]
101101
[assembly: InternalsVisibleTo("UnityEngine.Common")]
102+
[assembly: InternalsVisibleTo("Unity.UI.Builder.Editor")]
103+
[assembly: InternalsVisibleTo("Unity.UI.Builder.EditorTests")]
102104
[assembly: InternalsVisibleTo("Unity.GraphViewTestUtilities.Editor")]
103105
[assembly: InternalsVisibleTo("Unity.ProBuilder.Editor")]
104106
[assembly: InternalsVisibleTo("Unity.2D.Sprite.Editor")]

Editor/Mono/AssetDatabase/AssetDatabase.bindings.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,15 @@ public enum ForceReserializeAssetsOptions
1919
ReserializeAssetsAndMetadata = ReserializeAssets | ReserializeMetadata
2020
}
2121

22+
internal enum ImportPackageOptions
23+
{
24+
Default = 0,
25+
NoGUI = 1 << 0,
26+
}
27+
2228
[NativeHeader("Modules/AssetDatabase/Editor/Public/AssetDatabase.h")]
2329
[NativeHeader("Modules/AssetDatabase/Editor/Public/AssetDatabaseUtility.h")]
30+
[NativeHeader("Editor/Src/PackageUtility.h")]
2431
public partial class AssetDatabase
2532
{
2633
[FreeFunction("AssetDatabase::ReSerializeAssetsForced")]
@@ -110,5 +117,18 @@ public static void ForceReserializeAssets()
110117

111118
[FreeFunction("AssetDatabase::GUIDFromExistingAssetPath")]
112119
extern internal static GUID GUIDFromExistingAssetPath(string path);
120+
121+
[FreeFunction("::ImportPackage")]
122+
extern private static bool ImportPackage(string packagePath, ImportPackageOptions options);
123+
//TODO: This API should be Obsoleted when there is time available to update all the uses of it in Package Manager packages
124+
public static void ImportPackage(string packagePath, bool interactive)
125+
{
126+
ImportPackage(packagePath, interactive ? ImportPackageOptions.Default : ImportPackageOptions.NoGUI);
127+
}
128+
129+
internal static bool ImportPackageImmediately(string packagePath)
130+
{
131+
return ImportPackage(packagePath, ImportPackageOptions.NoGUI);
132+
}
113133
}
114134
}

Editor/Mono/BuildPipeline/CodeStrippingUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ private static HashSet<string> CollectManagedTypeReferencesFromRoots(string dire
552552
// UnityEngine.UI references UnityEngine.Collider, which causes the inclusion of Physics and Physics2D modules if
553553
// UnityEngine.UI is referenced. UnityEngine.UI code is designed to only actually access Colliders if these modules
554554
// are used, so don't include references from UnityEngine.UI here.
555-
if (fileNames[i] == "UnityEngine.UI.dll")
555+
if (fileNames[i] == "Unity.ugui.dll")
556556
unityEngineUIAssemblyDefinition = assemblies[i];
557557
}
558558

Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,7 @@ private void ConvertPlayerDlltoCpp(string inputDirectory, string outputDirectory
423423
arguments.Add("--mono-runtime");
424424

425425
// Working around gcc bug 41091
426-
if (m_PlatformProvider.target == BuildTarget.StandaloneLinux ||
427-
m_PlatformProvider.target == BuildTarget.StandaloneLinux64 ||
428-
m_PlatformProvider.target == BuildTarget.StandaloneLinuxUniversal)
426+
if (m_PlatformProvider.target == BuildTarget.StandaloneLinux64)
429427
{
430428
arguments.Add("--disable-aggressive-inlining");
431429
}

Editor/Mono/BuildTarget.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ public enum BuildTarget
5353
// was NaCl = 16,
5454

5555
// Build a Linux standalone (i386 only).
56-
// TODO: Uncomment this attribute once HDRP plugin is updated in 2019.2.
57-
// [System.Obsolete("StandaloneLinux has been removed in 2019.2")]
56+
[System.Obsolete("StandaloneLinux has been removed in 2019.2")]
5857
StandaloneLinux = 17,
5958

6059
// Build a Windows x86_64 standalone.
@@ -70,8 +69,7 @@ public enum BuildTarget
7069
StandaloneLinux64 = 24,
7170

7271
// Build a Linux standalone (i386/x86_64 universal).
73-
// TODO: Uncomment this attribute once HDRP plugin is updated in 2019.2.
74-
// [System.Obsolete("StandaloneLinuxUniversal has been removed in 2019.2")]
72+
[System.Obsolete("StandaloneLinuxUniversal has been removed in 2019.2")]
7573
StandaloneLinuxUniversal = 25,
7674

7775
[System.Obsolete("Use WSAPlayer with Windows Phone 8.1 selected")]

Editor/Mono/ConsoleWindow.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ private void SearchField(Event e)
730730
}
731731
}
732732

733-
private static string StacktraceWithHyperlinks(string stacktraceText)
733+
internal static string StacktraceWithHyperlinks(string stacktraceText)
734734
{
735735
StringBuilder textWithHyperlinks = new StringBuilder();
736736
var lines = stacktraceText.Split(new string[] {"\n"}, StringSplitOptions.None);
@@ -747,7 +747,7 @@ private static string StacktraceWithHyperlinks(string stacktraceText)
747747
int lineIndex = filePathPart.LastIndexOf(":", StringComparison.Ordinal); // LastIndex because the url can contain ':' ex:"C:"
748748
if (lineIndex > 0)
749749
{
750-
int endLineIndex = filePathPart.IndexOf(")", StringComparison.Ordinal);
750+
int endLineIndex = filePathPart.LastIndexOf(")", StringComparison.Ordinal); // LastIndex because files or folder in the url can contain ')'
751751
if (endLineIndex > 0)
752752
{
753753
string lineString =
@@ -757,16 +757,19 @@ private static string StacktraceWithHyperlinks(string stacktraceText)
757757
textWithHyperlinks.Append(lines[i].Substring(0, filePathIndex));
758758
textWithHyperlinks.Append("<a href=\"" + filePath + "\"" + " line=\"" + lineString + "\">");
759759
textWithHyperlinks.Append(filePath + ":" + lineString);
760-
textWithHyperlinks.AppendLine("</a>)");
760+
textWithHyperlinks.Append("</a>)\n");
761761

762762
continue; // continue to evade the default case
763763
}
764764
}
765765
}
766766
}
767767
// default case if no hyperlink : we just write the line
768-
textWithHyperlinks.AppendLine(lines[i]);
768+
textWithHyperlinks.Append(lines[i] + "\n");
769769
}
770+
// Remove the last \n
771+
if (textWithHyperlinks.Length > 0) // textWithHyperlinks always ends with \n if it is not empty
772+
textWithHyperlinks.Remove(textWithHyperlinks.Length - 1, 1);
770773

771774
return textWithHyperlinks.ToString();
772775
}

Editor/Mono/GUI/TreeView/GameObjectTreeViewGUI.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using UnityEditor.IMGUI.Controls;
1111
using UnityEditor.SceneManagement;
1212
using UnityEngine;
13+
using UnityEngine.Assertions.Comparers;
1314
using UnityEngine.SceneManagement;
1415
using Object = UnityEngine.Object;
1516

@@ -76,6 +77,7 @@ public override void OnInitialize()
7677
dataSource.beforeReloading += SubSceneGUI.FetchSubSceneInfo;
7778
m_PrevScollPos = m_TreeView.state.scrollPos.y;
7879
m_PrevTotalHeight = m_TreeView.GetTotalRect().height;
80+
k_BaseIndent = SceneVisibilityHierarchyGUI.utilityBarWidth;
7981
}
8082

8183
private void SceneVisibilityManagerOnVisibilityChanged()
@@ -333,11 +335,8 @@ override protected void DoItemGUI(Rect rect, int row, TreeViewItem item, bool se
333335
useBoldFont = (goItem.scene == SceneManager.GetActiveScene()) || IsPrefabStageHeader(goItem);
334336
}
335337

336-
SceneVisibilityHierarchyGUI.DoItemGUI(rect, goItem, selected && !IsRenaming(item.id), m_TreeView.hoveredItem == goItem, focused, isDragging);
337-
338-
rect.xMin += SceneVisibilityHierarchyGUI.utilityBarWidth;
339-
340338
base.DoItemGUI(rect, row, item, selected, focused, useBoldFont);
339+
SceneVisibilityHierarchyGUI.DoItemGUI(rect, goItem, selected && !IsRenaming(item.id), m_TreeView.hoveredItem == goItem, focused, isDragging);
341340

342341
if (goItem.isSceneHeader)
343342
{
@@ -356,7 +355,7 @@ override protected void DoItemGUI(Rect rect, int row, TreeViewItem item, bool se
356355

357356
protected override Rect GetDropTargetRect(Rect rect)
358357
{
359-
rect.xMin -= SceneVisibilityHierarchyGUI.utilityBarWidth;
358+
rect.xMin += SceneVisibilityHierarchyGUI.utilityBarWidth;
360359

361360
return rect;
362361
}
@@ -367,7 +366,9 @@ protected void DoAdditionalSceneHeaderGUI(GameObjectTreeViewItem goItem, Rect re
367366
const float optionsButtonWidth = 16f;
368367
const float optionsButtonHeight = 6f;
369368
const float margin = 4f;
369+
370370
Rect buttonRect = new Rect(rect.width - optionsButtonWidth - margin, rect.y + (rect.height - optionsButtonHeight) * 0.5f, optionsButtonWidth, rect.height);
371+
371372
if (Event.current.type == EventType.Repaint)
372373
GameObjectStyles.optionsButtonStyle.Draw(buttonRect, false, false, false, false);
373374

Editor/Mono/GUI/TreeView/TreeViewGUI.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ virtual protected void DoItemGUI(Rect rect, int row, TreeViewItem item, bool sel
257257
// Draw drop marker
258258
if (isDropTarget)
259259
{
260-
GetDropTargetRect(rect);
261-
Styles.lineStyle.Draw(rect, GUIContent.none, true, true, false, false);
260+
Styles.lineStyle.Draw(GetDropTargetRect(rect), GUIContent.none, true, true, false, false);
262261
}
263262

264263
// Show insertion marker below this item (rendered end of rows)
@@ -398,6 +397,7 @@ virtual public void BeginPingItem(TreeViewItem item, float topPixelOfRow, float
398397
topPixelOfRow,
399398
k_IconWidth + k_SpaceBetweenIconAndText + contentSize.x + iconTotalPadding,
400399
contentSize.y);
400+
401401
m_Ping.m_AvailableWidth = availableWidth;
402402

403403
int row = m_TreeView.data.GetRow(item.id);

Editor/Mono/Inspector/AssemblyDefinitionImporterInspector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ static void LoadAssemblyDefintionState(AssemblyDefinitionState state, string pat
547547

548548
// If the .asmdef has no references (true for newly created .asmdef), then use GUIDs.
549549
// Otherwise do not use GUIDs. This value might be changed below if any reference is a GUID.
550-
state.useGUIDs = (data.references != null && data.references.Length > 0);
550+
state.useGUIDs = (data.references == null || data.references.Length == 0);
551551

552552
if (data.versionDefines != null)
553553
{

0 commit comments

Comments
 (0)