Skip to content

Commit eb7074d

Browse files
author
Unity Technologies
committed
Unity 2019.3.0a2 C# reference source code
1 parent 904b54f commit eb7074d

File tree

386 files changed

+10358
-7694
lines changed

Some content is hidden

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

386 files changed

+10358
-7694
lines changed

Editor/Mono/2D/SpriteAtlas/SpriteAtlasInspector.cs

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Styles
6464
public readonly GUIContent packButton = EditorGUIUtility.TrTextContent("Pack Preview", "Pack this atlas.");
6565

6666
public readonly GUIContent disabledPackLabel = EditorGUIUtility.TrTextContent("Sprite Atlas packing is disabled. Enable it in Edit > Settings > Editor.", null, EditorGUIUtility.GetHelpIcon(MessageType.Info));
67-
public readonly GUIContent packableListLabel = EditorGUIUtility.TrTextContent("Objects for Packing", "Only accept Folder, Sprite Sheet(Texture) and Sprite.");
67+
public readonly GUIContent packableListLabel = EditorGUIUtility.TrTextContent("Objects for Packing", "Only accept Folder, Sprite Sheet (Texture) and Sprite.");
6868

6969
public readonly GUIContent notPowerOfTwoWarning = EditorGUIUtility.TrTextContent("This scale will produce a Sprite Atlas variant with a packed texture that is NPOT (non - power of two). This may cause visual artifacts in certain compression/texture formats.");
7070

@@ -96,6 +96,15 @@ public Styles()
9696

9797
private static Styles s_Styles;
9898

99+
private static Styles styles
100+
{
101+
get
102+
{
103+
s_Styles = s_Styles ?? new Styles();
104+
return s_Styles;
105+
}
106+
}
107+
99108
private enum AtlasType { Undefined = -1, Master = 0, Variant = 1 }
100109

101110
private SerializedProperty m_FilterMode;
@@ -231,7 +240,7 @@ void AddPackable(ReorderableList list)
231240
{
232241
ObjectSelector.get.Show(null, typeof(Object), null, false);
233242
ObjectSelector.get.searchFilter = "t:sprite t:texture2d t:folder";
234-
ObjectSelector.get.objectSelectorID = s_Styles.packableSelectorHash;
243+
ObjectSelector.get.objectSelectorID = styles.packableSelectorHash;
235244
}
236245

237246
void RemovePackable(ReorderableList list)
@@ -244,7 +253,7 @@ void RemovePackable(ReorderableList list)
244253
void DrawPackableElement(Rect rect, int index, bool selected, bool focused)
245254
{
246255
var property = m_Packables.GetArrayElementAtIndex(index);
247-
var controlID = EditorGUIUtility.GetControlID(s_Styles.packableElementHash, FocusType.Passive);
256+
var controlID = EditorGUIUtility.GetControlID(styles.packableElementHash, FocusType.Passive);
248257
var previousObject = property.objectReferenceValue;
249258

250259
var changedObject = EditorGUI.DoObjectField(rect, rect, controlID, previousObject, typeof(Object), null, ValidateObjectForPackableFieldAssignment, false);
@@ -263,8 +272,6 @@ void DrawPackableElement(Rect rect, int index, bool selected, bool focused)
263272

264273
public override void OnInspectorGUI()
265274
{
266-
s_Styles = s_Styles ?? new Styles();
267-
268275
// Ensure changes done through script are reflected immediately in Inspector by Syncing m_TempPlatformSettings with Actual Settings.
269276
SyncPlatformSettings();
270277

@@ -295,7 +302,7 @@ public override void OnInspectorGUI()
295302
|| EditorSettings.spritePackerMode == SpritePackerMode.AlwaysOnAtlas);
296303
if (spriteAtlasPackignEnabled)
297304
{
298-
if (GUILayout.Button(s_Styles.packButton, GUILayout.ExpandWidth(false)))
305+
if (GUILayout.Button(styles.packButton, GUILayout.ExpandWidth(false)))
299306
{
300307
SpriteAtlas[] spriteAtlases = new SpriteAtlas[targets.Length];
301308
for (int i = 0; i < spriteAtlases.Length; ++i)
@@ -311,7 +318,7 @@ public override void OnInspectorGUI()
311318
}
312319
else
313320
{
314-
if (GUILayout.Button(s_Styles.disabledPackLabel, EditorStyles.helpBox))
321+
if (GUILayout.Button(styles.disabledPackLabel, EditorStyles.helpBox))
315322
{
316323
SettingsService.OpenProjectSettings("Project/Editor");
317324
}
@@ -330,7 +337,7 @@ private void HandleCommonSettingUI()
330337

331338
EditorGUI.BeginChangeCheck();
332339
EditorGUI.showMixedValue = atlasType == AtlasType.Undefined;
333-
atlasType = (AtlasType)EditorGUILayout.IntPopup(s_Styles.atlasTypeLabel, (int)atlasType, s_Styles.atlasTypeOptions, s_Styles.atlasTypeValues);
340+
atlasType = (AtlasType)EditorGUILayout.IntPopup(styles.atlasTypeLabel, (int)atlasType, styles.atlasTypeOptions, styles.atlasTypeValues);
334341
EditorGUI.showMixedValue = false;
335342
if (EditorGUI.EndChangeCheck())
336343
{
@@ -345,7 +352,7 @@ private void HandleCommonSettingUI()
345352
if (atlasType == AtlasType.Variant)
346353
{
347354
EditorGUI.BeginChangeCheck();
348-
EditorGUILayout.PropertyField(m_MasterAtlas, s_Styles.masterAtlasLabel);
355+
EditorGUILayout.PropertyField(m_MasterAtlas, styles.masterAtlasLabel);
349356
if (EditorGUI.EndChangeCheck())
350357
{
351358
// Apply modified properties here to have latest master atlas reflected in native codes.
@@ -359,17 +366,17 @@ private void HandleCommonSettingUI()
359366
}
360367
}
361368

362-
EditorGUILayout.PropertyField(m_BindAsDefault, s_Styles.bindAsDefaultLabel);
369+
EditorGUILayout.PropertyField(m_BindAsDefault, styles.bindAsDefaultLabel);
363370
}
364371

365372
private void HandleVariantSettingUI()
366373
{
367-
EditorGUILayout.LabelField(s_Styles.variantSettingLabel, EditorStyles.boldLabel);
368-
EditorGUILayout.PropertyField(m_VariantScale, s_Styles.variantMultiplierLabel);
374+
EditorGUILayout.LabelField(styles.variantSettingLabel, EditorStyles.boldLabel);
375+
EditorGUILayout.PropertyField(m_VariantScale, styles.variantMultiplierLabel);
369376

370377
// Test if the multiplier scale a power of two size (1024) into another power of 2 size.
371378
if (!Mathf.IsPowerOfTwo((int)(m_VariantScale.floatValue * 1024)))
372-
EditorGUILayout.HelpBox(s_Styles.notPowerOfTwoWarning.text, MessageType.Warning, true);
379+
EditorGUILayout.HelpBox(styles.notPowerOfTwoWarning.text, MessageType.Warning, true);
373380
}
374381

375382
private void HandleBoolToIntPropertyField(SerializedProperty prop, GUIContent content)
@@ -385,22 +392,22 @@ private void HandleBoolToIntPropertyField(SerializedProperty prop, GUIContent co
385392

386393
private void HandleMasterSettingUI()
387394
{
388-
EditorGUILayout.LabelField(s_Styles.packingParametersLabel, EditorStyles.boldLabel);
395+
EditorGUILayout.LabelField(styles.packingParametersLabel, EditorStyles.boldLabel);
389396

390-
HandleBoolToIntPropertyField(m_EnableRotation, s_Styles.enableRotationLabel);
391-
HandleBoolToIntPropertyField(m_EnableTightPacking, s_Styles.enableTightPackingLabel);
392-
EditorGUILayout.IntPopup(m_Padding, s_Styles.paddingOptions, s_Styles.paddingValues, s_Styles.paddingLabel);
397+
HandleBoolToIntPropertyField(m_EnableRotation, styles.enableRotationLabel);
398+
HandleBoolToIntPropertyField(m_EnableTightPacking, styles.enableTightPackingLabel);
399+
EditorGUILayout.IntPopup(m_Padding, styles.paddingOptions, styles.paddingValues, styles.paddingLabel);
393400

394401
GUILayout.Space(EditorGUI.kSpacing);
395402
}
396403

397404
private void HandleTextureSettingUI()
398405
{
399-
EditorGUILayout.LabelField(s_Styles.textureSettingLabel, EditorStyles.boldLabel);
406+
EditorGUILayout.LabelField(styles.textureSettingLabel, EditorStyles.boldLabel);
400407

401-
HandleBoolToIntPropertyField(m_Readable, s_Styles.readWrite);
402-
HandleBoolToIntPropertyField(m_GenerateMipMaps, s_Styles.generateMipMapLabel);
403-
HandleBoolToIntPropertyField(m_UseSRGB, s_Styles.sRGBLabel);
408+
HandleBoolToIntPropertyField(m_Readable, styles.readWrite);
409+
HandleBoolToIntPropertyField(m_GenerateMipMaps, styles.generateMipMapLabel);
410+
HandleBoolToIntPropertyField(m_UseSRGB, styles.sRGBLabel);
404411
EditorGUILayout.PropertyField(m_FilterMode);
405412

406413
var showAniso = !m_FilterMode.hasMultipleDifferentValues && !m_GenerateMipMaps.hasMultipleDifferentValues
@@ -415,7 +422,7 @@ private void HandleTextureSettingUI()
415422

416423
private void HandlePlatformSettingUI()
417424
{
418-
int shownTextureFormatPage = EditorGUILayout.BeginPlatformGrouping(m_ValidPlatforms.ToArray(), s_Styles.defaultPlatformLabel);
425+
int shownTextureFormatPage = EditorGUILayout.BeginPlatformGrouping(m_ValidPlatforms.ToArray(), styles.defaultPlatformLabel);
419426
var defaultPlatformSettings = m_TempPlatformSettings[TextureImporterInspector.s_DefaultPlatformName];
420427
if (shownTextureFormatPage == -1)
421428
{
@@ -515,11 +522,11 @@ private void HandlePackableListUI()
515522
}
516523
break;
517524
case EventType.ValidateCommand:
518-
if (currentEvent.commandName == ObjectSelector.ObjectSelectorClosedCommand && ObjectSelector.get.objectSelectorID == s_Styles.packableSelectorHash)
525+
if (currentEvent.commandName == ObjectSelector.ObjectSelectorClosedCommand && ObjectSelector.get.objectSelectorID == styles.packableSelectorHash)
519526
usedEvent = true;
520527
break;
521528
case EventType.ExecuteCommand:
522-
if (currentEvent.commandName == ObjectSelector.ObjectSelectorClosedCommand && ObjectSelector.get.objectSelectorID == s_Styles.packableSelectorHash)
529+
if (currentEvent.commandName == ObjectSelector.ObjectSelectorClosedCommand && ObjectSelector.get.objectSelectorID == styles.packableSelectorHash)
523530
{
524531
var obj = ObjectSelector.GetCurrentObject();
525532
if (IsPackable(obj))
@@ -534,7 +541,7 @@ private void HandlePackableListUI()
534541
}
535542

536543
// Handle Foldout after we handle the current event because Foldout might process the drag and drop event and used it.
537-
m_PackableListExpanded = EditorGUI.Foldout(rect, m_PackableListExpanded, s_Styles.packableListLabel, true);
544+
m_PackableListExpanded = EditorGUI.Foldout(rect, m_PackableListExpanded, styles.packableListLabel, true);
538545

539546
if (usedEvent)
540547
currentEvent.Use();
@@ -593,7 +600,7 @@ public override void OnPreviewSettings()
593600
{
594601
// Do not allow changing of pages when multiple atlases is selected.
595602
if (targets.Length == 1 && m_OptionDisplays != null && m_OptionValues != null && m_TotalPages > 1)
596-
m_PreviewPage = EditorGUILayout.IntPopup(m_PreviewPage, m_OptionDisplays, m_OptionValues, s_Styles.preDropDown, GUILayout.MaxWidth(50));
603+
m_PreviewPage = EditorGUILayout.IntPopup(m_PreviewPage, m_OptionDisplays, m_OptionValues, styles.preDropDown, GUILayout.MaxWidth(50));
597604
else
598605
m_PreviewPage = 0;
599606

@@ -602,14 +609,14 @@ public override void OnPreviewSettings()
602609
Texture2D t = m_PreviewTextures[m_PreviewPage];
603610

604611
if (TextureUtil.HasAlphaTextureFormat(t.format) || (m_PreviewAlphaTextures != null && m_PreviewAlphaTextures.Length > 0))
605-
m_ShowAlpha = GUILayout.Toggle(m_ShowAlpha, m_ShowAlpha ? s_Styles.alphaIcon : s_Styles.RGBIcon, s_Styles.previewButton);
612+
m_ShowAlpha = GUILayout.Toggle(m_ShowAlpha, m_ShowAlpha ? styles.alphaIcon : styles.RGBIcon, styles.previewButton);
606613

607614
int mipCount = Mathf.Max(1, TextureUtil.GetMipmapCount(t));
608615
if (mipCount > 1)
609616
{
610-
GUILayout.Box(s_Styles.smallZoom, s_Styles.previewLabel);
611-
m_MipLevel = Mathf.Round(GUILayout.HorizontalSlider(m_MipLevel, mipCount - 1, 0, s_Styles.previewSlider, s_Styles.previewSliderThumb, GUILayout.MaxWidth(64)));
612-
GUILayout.Box(s_Styles.largeZoom, s_Styles.previewLabel);
617+
GUILayout.Box(styles.smallZoom, styles.previewLabel);
618+
m_MipLevel = Mathf.Round(GUILayout.HorizontalSlider(m_MipLevel, mipCount - 1, 0, styles.previewSlider, styles.previewSliderThumb, GUILayout.MaxWidth(64)));
619+
GUILayout.Box(styles.largeZoom, styles.previewLabel);
613620
}
614621
}
615622
}

Editor/Mono/Annotation/SceneViewCameraWindow.cs

Lines changed: 5 additions & 10 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.");
69-
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.");
70+
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.");
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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,13 @@
4242
[assembly: InternalsVisibleTo("UnityEditor.WindowsStandalone.Extensions")]
4343
[assembly: InternalsVisibleTo("UnityEditor.OSXStandalone.Extensions")]
4444
[assembly: InternalsVisibleTo("UnityEditor.Lumin.Extensions")]
45-
[assembly: InternalsVisibleTo("UnityEditor.BJM.Extensions")]
45+
[assembly: InternalsVisibleTo("UnityEditor.Stadia.Extensions")]
4646
[assembly: InternalsVisibleTo("UnityEditor.Networking")]
4747
[assembly: InternalsVisibleTo("UnityEngine.Networking")]
4848
[assembly: InternalsVisibleTo("Unity.Analytics.Editor")]
4949
[assembly: InternalsVisibleTo("UnityEditor.Analytics")]
5050
[assembly: InternalsVisibleTo("UnityEditor.Purchasing")]
5151
[assembly: InternalsVisibleTo("UnityEditor.Lumin")]
52-
[assembly: InternalsVisibleTo("UnityEditor.BJM")]
5352
[assembly: InternalsVisibleTo("UnityEditor.Switch.Extensions")]
5453
[assembly: InternalsVisibleTo("UnityEditor.EditorTestsRunner")]
5554
[assembly: InternalsVisibleTo("UnityEditor.TestRunner")]
@@ -99,6 +98,8 @@
9998
[assembly: InternalsVisibleTo("Unity.InternalAPIEditorBridgeDev.005")]
10099
[assembly: InternalsVisibleTo("Unity.XR.Remoting.Editor")]
101100
[assembly: InternalsVisibleTo("UnityEngine.Common")]
101+
[assembly: InternalsVisibleTo("Unity.UI.Builder.Editor")]
102+
[assembly: InternalsVisibleTo("Unity.UI.Builder.EditorTests")]
102103
[assembly: InternalsVisibleTo("Unity.GraphViewTestUtilities.Editor")]
103104
[assembly: InternalsVisibleTo("Unity.ProBuilder.Editor")]
104105
[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
}

0 commit comments

Comments
 (0)