Skip to content

Commit 0f8d03f

Browse files
author
Unity Technologies
committed
Unity 2018.3.0a3 C# reference source code
1 parent 8c06031 commit 0f8d03f

File tree

163 files changed

+4053
-2361
lines changed

Some content is hidden

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

163 files changed

+4053
-2361
lines changed

Editor/Mono/2D/Common/ScriptBindings/SpriteEditorExtension.bindings.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using UnityEngine;
66
using UnityEditor;
77
using UnityEngine.Bindings;
8+
using UnityEngine.U2D;
89

910
namespace UnityEditor.Experimental.U2D
1011
{
@@ -21,9 +22,13 @@ public static void SetSpriteID(this Sprite sprite, GUID guid)
2122
SetSpriteIDScripting(sprite, guid.ToString());
2223
}
2324

24-
[FreeFunction("SpriteEditorExtension::GetSpriteIDScripting")]
2525
private static extern string GetSpriteIDScripting([NotNull] Sprite sprite);
26-
[FreeFunction("SpriteEditorExtension::SetSpriteIDScripting")]
2726
private static extern void SetSpriteIDScripting([NotNull] Sprite sprite, string spriteID);
27+
internal static extern SpriteAtlas GetActiveAtlas([NotNull] this Sprite sprite);
28+
internal static extern string GetActiveAtlasName([NotNull] this Sprite sprite);
29+
internal static extern Texture2D GetActiveAtlasTexture([NotNull] this Sprite sprite);
30+
internal static extern Rect GetActiveAtlasTextureRect([NotNull] this Sprite sprite);
31+
internal static extern Vector2 GetActiveAtlasTextureRectOffset([NotNull] this Sprite sprite);
32+
internal static extern Texture2D GetActiveAtlasAlphaTexture([NotNull] this Sprite sprite);
2833
}
2934
}

Editor/Mono/2D/SpriteAtlas/EditorSpriteAtlas.bindings.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ namespace UnityEditor.U2D
1515
public class SpriteAtlasUtility
1616
{
1717
[FreeFunction("CollectAllSpriteAtlasesAndPack")]
18-
extern public static void PackAllAtlases(BuildTarget target);
18+
extern public static void PackAllAtlases(BuildTarget target, bool canCancel = true);
1919

2020
[FreeFunction("PackSpriteAtlases")]
21-
extern public static void PackAtlases(SpriteAtlas[] atlases, BuildTarget target);
21+
extern public static void PackAtlases(SpriteAtlas[] atlases, BuildTarget target, bool canCancel = true);
2222
}
2323

2424
[StructLayout(LayoutKind.Sequential)]
@@ -95,5 +95,6 @@ public static class SpriteAtlasExtensions
9595
extern internal static Texture2D[] GetPreviewTextures(this SpriteAtlas spriteAtlas);
9696
extern internal static Texture2D[] GetPreviewAlphaTextures(this SpriteAtlas spriteAtlas);
9797
extern internal static TextureFormat GetTextureFormat(this SpriteAtlas spriteAtlas, BuildTarget target);
98+
extern internal static Sprite[] GetPackedSprites(this SpriteAtlas spriteAtlas);
9899
}
99100
}

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public override int DrawMaxSize(int defaultValue, bool isMixedValue, bool isDisa
3737

3838
class Styles
3939
{
40-
public readonly GUIStyle dropzoneStyle = new GUIStyle("BoldLabel");
40+
public readonly GUIStyle dropzoneStyle = "DropzoneStyle";
4141
public readonly GUIStyle preDropDown = "preDropDown";
4242
public readonly GUIStyle previewButton = "preButton";
4343
public readonly GUIStyle previewSlider = "preSlider";
@@ -86,9 +86,6 @@ class Styles
8686

8787
public Styles()
8888
{
89-
dropzoneStyle.alignment = TextAnchor.MiddleCenter;
90-
dropzoneStyle.border = new RectOffset(10, 10, 10, 10);
91-
9289
paddingOptions = new GUIContent[paddingValues.Length];
9390
for (var i = 0; i < paddingValues.Length; ++i)
9491
paddingOptions[i] = EditorGUIUtility.TextContent(paddingValues[i].ToString());

Editor/Mono/Animation/AnimationWindow/CurveEditor.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,21 +1693,12 @@ float SnapValue(float v)
16931693

16941694
public static GUIStyle none = new GUIStyle();
16951695
public static GUIStyle labelTickMarksY = "CurveEditorLabelTickMarks";
1696-
public static GUIStyle labelTickMarksX;
1696+
public static GUIStyle labelTickMarksX = "CurveEditorLabelTickmarksOverflow";
16971697
public static GUIStyle selectionRect = "SelectionRect";
16981698

16991699
public static GUIStyle dragLabel = "ProfilerBadge";
1700-
public static GUIStyle axisLabelNumberField = new GUIStyle(EditorStyles.miniTextField);
1701-
public static GUIStyle rightAlignedLabel = new GUIStyle(EditorStyles.label);
1702-
1703-
static Styles()
1704-
{
1705-
axisLabelNumberField.alignment = TextAnchor.UpperRight;
1706-
labelTickMarksY.contentOffset = Vector2.zero; // TODO: Fix this in style when Editor has been merged to Trunk (31/8/2011)
1707-
labelTickMarksX = new GUIStyle(labelTickMarksY);
1708-
labelTickMarksX.clipping = TextClipping.Overflow;
1709-
rightAlignedLabel.alignment = TextAnchor.UpperRight;
1710-
}
1700+
public static GUIStyle axisLabelNumberField = "AxisLabelNumberField";
1701+
public static GUIStyle rightAlignedLabel = "CurveEditorRightAlignedLabel";
17111702
}
17121703

17131704
Vector2 GetGUIPoint(CurveWrapper cw, Vector3 point)

Editor/Mono/Animation/AnimationWindow/DopeSheetEditor.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -803,15 +803,6 @@ private void HandleDragAndDropToEmptyArea()
803803

804804
private void DoSpriteDropAfterGeneratingNewDopeline(AnimationClip animationClip, EditorCurveBinding? spriteBinding)
805805
{
806-
if (DragAndDrop.objectReferences.Length == 1)
807-
{
808-
UsabilityAnalytics.Event("Sprite Drag and Drop", "Drop single sprite into empty dopesheet", "null", 1);
809-
}
810-
else
811-
{
812-
UsabilityAnalytics.Event("Sprite Drag and Drop", "Drop multiple sprites into empty dopesheet", "null", 1);
813-
}
814-
815806
// Create the new curve for our sprites
816807
AnimationWindowCurve newCurve = new AnimationWindowCurve(animationClip, (EditorCurveBinding)spriteBinding, typeof(Sprite));
817808

@@ -1185,11 +1176,6 @@ private bool DoDragAndDrop(DopeLine dopeLine, Rect position, bool perform)
11851176

11861177
if (perform)
11871178
{
1188-
if (DragAndDrop.objectReferences.Length == 1)
1189-
UsabilityAnalytics.Event("Sprite Drag and Drop", "Drop single sprite into existing dopeline", "null", 1);
1190-
else
1191-
UsabilityAnalytics.Event("Sprite Drag and Drop", "Drop multiple sprites into existing dopeline", "null", 1);
1192-
11931179
float time = Mathf.Max(state.PixelToTime(Event.current.mousePosition.x, AnimationWindowState.SnapMode.SnapToClipFrame), 0f);
11941180
AnimationWindowCurve targetCurve = GetCurveOfType(dopeLine, targetType);
11951181
PerformDragAndDrop(targetCurve, time);

Editor/Mono/AssemblyInfo/AssemblyInfo.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
[assembly: InternalsVisibleTo("Unity.Burst.Editor")]
1111
[assembly: InternalsVisibleTo("Unity.CollabProxy.Editor")]
1212
[assembly: InternalsVisibleTo("Unity.CollabProxy.EditorTests")]
13+
[assembly: InternalsVisibleTo("Unity.CollabProxy.UI")]
14+
[assembly: InternalsVisibleTo("Unity.CollabProxy.UI.Tests")]
15+
[assembly: InternalsVisibleTo("Unity.CollabProxy.Client")]
16+
[assembly: InternalsVisibleTo("Unity.CollabProxy.Client.Tests")]
1317
[assembly: InternalsVisibleTo("UnityEditor.Advertisements")]
1418
[assembly: InternalsVisibleTo("Unity.PackageManager")]
1519
[assembly: InternalsVisibleTo("Unity.PackageManagerStandalone")]
@@ -88,6 +92,5 @@
8892
[assembly: InternalsVisibleTo("Unity.InternalAPIEditorBridgeDev.003")]
8993
[assembly: InternalsVisibleTo("Unity.InternalAPIEditorBridgeDev.004")]
9094
[assembly: InternalsVisibleTo("Unity.InternalAPIEditorBridgeDev.005")]
91-
[assembly: InternalsVisibleTo("com.unity.editor.resources-testable")]
9295

9396
[assembly: AssemblyIsEditorAssembly]

Editor/Mono/AssetStore/AssetStoreInstaBuyWindow.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ static public AssetStoreInstaBuyWindow ShowAssetStoreInstaBuyWindow(AssetStoreAs
5454
w.m_PaymentMethodCard = paymentMethodCard;
5555
w.m_PaymentMethodExpire = paymentMethodExpire;
5656
w.m_PriceText = priceText;
57-
UsabilityAnalytics.Track(string.Format("/AssetStore/ShowInstaBuy/{0}/{1}", w.m_Asset.packageID, w.m_Asset.id));
5857
return w;
5958
}
6059

@@ -71,7 +70,6 @@ static public void ShowAssetStoreInstaBuyWindowBuilding(AssetStoreAsset asset)
7170
w.m_Purchasing = PurchaseStatus.StartBuild;
7271
w.m_BuildAttempts = 1;
7372
asset.previewInfo.buildProgress = 0f;
74-
UsabilityAnalytics.Track(string.Format("/AssetStore/ShowInstaFree/{0}/{1}", w.m_Asset.packageID, w.m_Asset.id));
7573
}
7674

7775
private static GUIContent s_AssetStoreLogo;
@@ -218,15 +216,13 @@ void PasswordGUI()
218216
if (GUILayout.Button("Just put to basket..."))
219217
{
220218
AssetStore.Open(string.Format("content/{0}/basketpurchase", m_Asset.packageID));
221-
UsabilityAnalytics.Track(string.Format("/AssetStore/PutToBasket/{0}/{1}", m_Asset.packageID, m_Asset.id));
222219
m_Asset = null;
223220
this.Close();
224221
GUIUtility.ExitGUI();
225222
}
226223
GUILayout.FlexibleSpace();
227224
if (GUILayout.Button("Cancel"))
228225
{
229-
UsabilityAnalytics.Track(string.Format("/AssetStore/CancelInstaBuy/{0}/{1}", m_Asset.packageID, m_Asset.id));
230226
m_Asset = null;
231227
this.Close();
232228
GUIUtility.ExitGUI();
@@ -273,14 +269,12 @@ void PurchaseSuccessGUI()
273269
GUILayout.FlexibleSpace();
274270
if (GUILayout.Button("Close"))
275271
{
276-
UsabilityAnalytics.Track(string.Format("/AssetStore/PurchaseOk/{0}/{1}", m_Asset.packageID, m_Asset.id));
277272
m_Asset = null;
278273
this.Close();
279274
}
280275
GUILayout.Space(5);
281276
if (GUILayout.Button("Import package"))
282277
{
283-
UsabilityAnalytics.Track(string.Format("/AssetStore/PurchaseOkImport/{0}/{1}", m_Asset.packageID, m_Asset.id));
284278
m_BuildAttempts = 1;
285279
m_Asset.previewInfo.buildProgress = 0f;
286280
m_Purchasing = PurchaseStatus.StartBuild;
@@ -361,15 +355,13 @@ void PurchaseDeclinedGUI()
361355
GUILayout.FlexibleSpace();
362356
if (GUILayout.Button("Close"))
363357
{
364-
UsabilityAnalytics.Track(string.Format("/AssetStore/DeclinedAbort/{0}/{1}", m_Asset.packageID, m_Asset.id));
365358
m_Asset = null;
366359
Close();
367360
}
368361
GUILayout.Space(5);
369362
if (GUILayout.Button("Put to basket"))
370363
{
371364
AssetStore.Open(string.Format("content/{0}/basketpurchase", m_Asset.packageID));
372-
UsabilityAnalytics.Track(string.Format("/AssetStore/DeclinedPutToBasket/{0}/{1}", m_Asset.packageID, m_Asset.id));
373365
m_Asset = null;
374366
Close();
375367
}
@@ -434,7 +426,6 @@ void CompletePurchase()
434426
EditorUtility.DisplayDialog("Purchase failed", msg + " This purchase has been cancelled.",
435427
"Add this item to basket", "Cancel");
436428
});
437-
UsabilityAnalytics.Track(string.Format("/AssetStore/InstaBuy/{0}/{1}", m_Asset.packageID, m_Asset.id));
438429
}
439430

440431
void BuildPackage()

Editor/Mono/AssetStore/AssetStoreLoginWIndow.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ static public void ShowAssetStoreLoginWindow(string loginReason, LoginCallback c
7878
w.m_LoginCallback = callback;
7979
w.m_LoginReason = loginReason;
8080
w.m_LoginRemoteMessage = null;
81-
UsabilityAnalytics.Track("/AssetStore/Login");
8281
}
8382

8483
static GUIContent s_AssetStoreLogo;

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

Lines changed: 11 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,26 @@ public static Color GetEffectColor(AudioMixerEffectController effect)
4747

4848
public class Styles
4949
{
50-
public GUIStyle headerStyle = new GUIStyle(EditorStyles.boldLabel);
51-
public GUIStyle reorderableListLabel = new GUIStyle("PR Label");
50+
public GUIStyle headerStyle = GetStyle("AM HeaderStyle");
51+
public GUIStyle reorderableListLabel = GetStyle("ReorderableList");
5252
public GUIStyle regionBg = GetStyle("RegionBg");
5353
public GUIStyle channelStripVUMeterBg = GetStyle("ChannelStripVUMeterBg");
54-
public GUIStyle channelStripAreaBackground = "CurveEditorBackground"; //"flow background";
54+
public GUIStyle channelStripAreaBackground = GetStyle("CurveEditorBackground"); //"flow background";
5555
public GUIStyle channelStripBg = GetStyle("ChannelStripBg");
5656
public GUIStyle duckingMarker = GetStyle("ChannelStripDuckingMarker");
5757
public GUIStyle channelStripAttenuationMarkerSquare = GetStyle("ChannelStripAttenuationMarkerSquare");
58-
public GUIStyle channelStripHeaderStyle;
58+
public GUIStyle channelStripHeaderStyle = GetStyle("AM ChannelStripHeaderStyle");
5959
public GUIStyle soloToggle = GetStyle("SoloToggle");
6060
public GUIStyle muteToggle = GetStyle("MuteToggle");
6161
public GUIStyle bypassToggle = GetStyle("BypassToggle");
6262
public GUIStyle circularToggle = GetStyle("CircularToggle");
63-
public GUIStyle totalVULevel = new GUIStyle(EditorStyles.label);
64-
public GUIStyle attenuationBar = "ChannelStripAttenuationBar";
65-
public GUIStyle effectBar = "ChannelStripEffectBar";
66-
public GUIStyle sendReturnBar = "ChannelStripSendReturnBar";
67-
public GUIStyle effectName = new GUIStyle(EditorStyles.miniLabel);
68-
public GUIStyle vuValue = new GUIStyle(EditorStyles.miniLabel);
69-
public GUIStyle mixerHeader = new GUIStyle(EditorStyles.largeLabel);
63+
public GUIStyle totalVULevel = GetStyle("AM TotalVuLabel");
64+
public GUIStyle attenuationBar = GetStyle("ChannelStripAttenuationBar");
65+
public GUIStyle effectBar = GetStyle("ChannelStripEffectBar");
66+
public GUIStyle sendReturnBar = GetStyle("ChannelStripSendReturnBar");
67+
public GUIStyle effectName = GetStyle("AM EffectName");
68+
public GUIStyle vuValue = GetStyle("AM VuValue");
69+
public GUIStyle mixerHeader = GetStyle("AM MixerHeader2");
7070
public GUIStyle warningOverlay = GetStyle("WarningOverlay");
7171
public Texture2D scrollShadowTexture = EditorGUIUtility.FindTexture("ScrollShadow");
7272
public Texture2D leftToRightShadowTexture = EditorGUIUtility.FindTexture("LeftToRightShadow");
@@ -92,52 +92,7 @@ static GUIStyle GetStyle(string styleName)
9292

9393
public Styles()
9494
{
95-
headerStyle.alignment = TextAnchor.MiddleLeft;
96-
97-
Texture2D transparent = reorderableListLabel.hover.background;
98-
reorderableListLabel.normal.background = transparent;
99-
reorderableListLabel.active.background = transparent;
100-
reorderableListLabel.focused.background = transparent;
101-
reorderableListLabel.onNormal.background = transparent;
102-
reorderableListLabel.onHover.background = transparent;
103-
reorderableListLabel.onActive.background = transparent;
104-
reorderableListLabel.onFocused.background = transparent;
105-
reorderableListLabel.padding.left = reorderableListLabel.padding.right = 0;
106-
reorderableListLabel.alignment = TextAnchor.MiddleLeft;
107-
10895
scrollShadowTexture = EditorGUIUtility.FindTexture("ScrollShadow");
109-
110-
channelStripHeaderStyle = new GUIStyle(EditorStyles.boldLabel);
111-
channelStripHeaderStyle.alignment = TextAnchor.MiddleLeft;
112-
channelStripHeaderStyle.fontSize = 11;
113-
channelStripHeaderStyle.fontStyle = FontStyle.Bold;
114-
channelStripHeaderStyle.wordWrap = false;
115-
channelStripHeaderStyle.clipping = TextClipping.Clip;
116-
channelStripHeaderStyle.padding = new RectOffset(4, 4, 4, 4);
117-
118-
totalVULevel.alignment = TextAnchor.MiddleRight;
119-
totalVULevel.padding.right = 20;
120-
121-
effectName.padding.left = 4;
122-
effectName.padding.top = 2;
123-
124-
vuValue.padding.left = 4;
125-
vuValue.padding.right = 4;
126-
vuValue.padding.top = 0;
127-
vuValue.alignment = TextAnchor.MiddleRight;
128-
vuValue.clipping = TextClipping.Overflow;
129-
130-
warningOverlay.alignment = TextAnchor.MiddleCenter;
131-
132-
mixerHeader.fontStyle = FontStyle.Bold;
133-
mixerHeader.fontSize = 17;
134-
mixerHeader.margin = new RectOffset();
135-
mixerHeader.padding = new RectOffset();
136-
mixerHeader.alignment = TextAnchor.UpperLeft;
137-
if (EditorGUIUtility.isProSkin)
138-
mixerHeader.normal.textColor = new Color(0.7f, 0.7f, 0.7f, 1.0f);
139-
else
140-
mixerHeader.normal.textColor = new Color(0.2f, 0.2f, 0.2f, 1.0f);
14196
}
14297
}
14398
static Styles s_Styles;

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

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ class GUIContents
113113
public GUIContent infoText;
114114
public GUIContent selectAudioMixer;
115115
public GUIContent output;
116-
public GUIStyle toolbarObjectField = new GUIStyle("ShurikenObjectField");
117-
public GUIStyle toolbarLabel = new GUIStyle(EditorStyles.miniLabel);
118-
public GUIStyle mixerHeader = new GUIStyle(EditorStyles.largeLabel);
116+
public GUIStyle toolbarObjectField = "AM ToolbarObjectField";
117+
public GUIStyle toolbarLabel = "AM ToolbarLabel";
118+
public GUIStyle mixerHeader = "AM MixerHeader";
119119

120120
public GUIContents()
121121
{
@@ -124,18 +124,6 @@ public GUIContents()
124124
infoText = EditorGUIUtility.TrTextContent("Create an AudioMixer asset from the Project Browser to get started");
125125
selectAudioMixer = EditorGUIUtility.TrTextContent("", "Select an Audio Mixer");
126126
output = EditorGUIUtility.TrTextContent("Output", "Select an Audio Mixer Group from another Audio Mixer to output to. If 'None' is selected then output is routed directly to the Audio Listener.");
127-
toolbarLabel.alignment = TextAnchor.MiddleLeft;
128-
toolbarObjectField.normal.textColor = toolbarLabel.normal.textColor;
129-
130-
mixerHeader.fontStyle = FontStyle.Bold;
131-
mixerHeader.fontSize = 17;
132-
mixerHeader.margin = new RectOffset();
133-
mixerHeader.padding = new RectOffset();
134-
mixerHeader.alignment = TextAnchor.MiddleLeft;
135-
if (!EditorGUIUtility.isProSkin)
136-
mixerHeader.normal.textColor = new Color(0.4f, 0.4f, 0.4f, 1.0f);
137-
else
138-
mixerHeader.normal.textColor = new Color(0.7f, 0.7f, 0.7f, 1.0f);
139127
}
140128
}
141129
private static GUIContents s_GuiContents;

0 commit comments

Comments
 (0)