Skip to content

Commit

Permalink
Unity 2018.3.0a3 C# reference source code
Browse files Browse the repository at this point in the history
  • Loading branch information
Unity Technologies committed Jul 2, 2018
1 parent 8c06031 commit 0f8d03f
Show file tree
Hide file tree
Showing 163 changed files with 4,053 additions and 2,361 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using UnityEngine;
using UnityEditor;
using UnityEngine.Bindings;
using UnityEngine.U2D;

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

[FreeFunction("SpriteEditorExtension::GetSpriteIDScripting")]
private static extern string GetSpriteIDScripting([NotNull] Sprite sprite);
[FreeFunction("SpriteEditorExtension::SetSpriteIDScripting")]
private static extern void SetSpriteIDScripting([NotNull] Sprite sprite, string spriteID);
internal static extern SpriteAtlas GetActiveAtlas([NotNull] this Sprite sprite);
internal static extern string GetActiveAtlasName([NotNull] this Sprite sprite);
internal static extern Texture2D GetActiveAtlasTexture([NotNull] this Sprite sprite);
internal static extern Rect GetActiveAtlasTextureRect([NotNull] this Sprite sprite);
internal static extern Vector2 GetActiveAtlasTextureRectOffset([NotNull] this Sprite sprite);
internal static extern Texture2D GetActiveAtlasAlphaTexture([NotNull] this Sprite sprite);
}
}
5 changes: 3 additions & 2 deletions Editor/Mono/2D/SpriteAtlas/EditorSpriteAtlas.bindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ namespace UnityEditor.U2D
public class SpriteAtlasUtility
{
[FreeFunction("CollectAllSpriteAtlasesAndPack")]
extern public static void PackAllAtlases(BuildTarget target);
extern public static void PackAllAtlases(BuildTarget target, bool canCancel = true);

[FreeFunction("PackSpriteAtlases")]
extern public static void PackAtlases(SpriteAtlas[] atlases, BuildTarget target);
extern public static void PackAtlases(SpriteAtlas[] atlases, BuildTarget target, bool canCancel = true);
}

[StructLayout(LayoutKind.Sequential)]
Expand Down Expand Up @@ -95,5 +95,6 @@ public static class SpriteAtlasExtensions
extern internal static Texture2D[] GetPreviewTextures(this SpriteAtlas spriteAtlas);
extern internal static Texture2D[] GetPreviewAlphaTextures(this SpriteAtlas spriteAtlas);
extern internal static TextureFormat GetTextureFormat(this SpriteAtlas spriteAtlas, BuildTarget target);
extern internal static Sprite[] GetPackedSprites(this SpriteAtlas spriteAtlas);
}
}
5 changes: 1 addition & 4 deletions Editor/Mono/2D/SpriteAtlas/SpriteAtlasInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public override int DrawMaxSize(int defaultValue, bool isMixedValue, bool isDisa

class Styles
{
public readonly GUIStyle dropzoneStyle = new GUIStyle("BoldLabel");
public readonly GUIStyle dropzoneStyle = "DropzoneStyle";
public readonly GUIStyle preDropDown = "preDropDown";
public readonly GUIStyle previewButton = "preButton";
public readonly GUIStyle previewSlider = "preSlider";
Expand Down Expand Up @@ -86,9 +86,6 @@ class Styles

public Styles()
{
dropzoneStyle.alignment = TextAnchor.MiddleCenter;
dropzoneStyle.border = new RectOffset(10, 10, 10, 10);

paddingOptions = new GUIContent[paddingValues.Length];
for (var i = 0; i < paddingValues.Length; ++i)
paddingOptions[i] = EditorGUIUtility.TextContent(paddingValues[i].ToString());
Expand Down
15 changes: 3 additions & 12 deletions Editor/Mono/Animation/AnimationWindow/CurveEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1693,21 +1693,12 @@ float SnapValue(float v)

public static GUIStyle none = new GUIStyle();
public static GUIStyle labelTickMarksY = "CurveEditorLabelTickMarks";
public static GUIStyle labelTickMarksX;
public static GUIStyle labelTickMarksX = "CurveEditorLabelTickmarksOverflow";
public static GUIStyle selectionRect = "SelectionRect";

public static GUIStyle dragLabel = "ProfilerBadge";
public static GUIStyle axisLabelNumberField = new GUIStyle(EditorStyles.miniTextField);
public static GUIStyle rightAlignedLabel = new GUIStyle(EditorStyles.label);

static Styles()
{
axisLabelNumberField.alignment = TextAnchor.UpperRight;
labelTickMarksY.contentOffset = Vector2.zero; // TODO: Fix this in style when Editor has been merged to Trunk (31/8/2011)
labelTickMarksX = new GUIStyle(labelTickMarksY);
labelTickMarksX.clipping = TextClipping.Overflow;
rightAlignedLabel.alignment = TextAnchor.UpperRight;
}
public static GUIStyle axisLabelNumberField = "AxisLabelNumberField";
public static GUIStyle rightAlignedLabel = "CurveEditorRightAlignedLabel";
}

Vector2 GetGUIPoint(CurveWrapper cw, Vector3 point)
Expand Down
14 changes: 0 additions & 14 deletions Editor/Mono/Animation/AnimationWindow/DopeSheetEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -803,15 +803,6 @@ private void HandleDragAndDropToEmptyArea()

private void DoSpriteDropAfterGeneratingNewDopeline(AnimationClip animationClip, EditorCurveBinding? spriteBinding)
{
if (DragAndDrop.objectReferences.Length == 1)
{
UsabilityAnalytics.Event("Sprite Drag and Drop", "Drop single sprite into empty dopesheet", "null", 1);
}
else
{
UsabilityAnalytics.Event("Sprite Drag and Drop", "Drop multiple sprites into empty dopesheet", "null", 1);
}

// Create the new curve for our sprites
AnimationWindowCurve newCurve = new AnimationWindowCurve(animationClip, (EditorCurveBinding)spriteBinding, typeof(Sprite));

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

if (perform)
{
if (DragAndDrop.objectReferences.Length == 1)
UsabilityAnalytics.Event("Sprite Drag and Drop", "Drop single sprite into existing dopeline", "null", 1);
else
UsabilityAnalytics.Event("Sprite Drag and Drop", "Drop multiple sprites into existing dopeline", "null", 1);

float time = Mathf.Max(state.PixelToTime(Event.current.mousePosition.x, AnimationWindowState.SnapMode.SnapToClipFrame), 0f);
AnimationWindowCurve targetCurve = GetCurveOfType(dopeLine, targetType);
PerformDragAndDrop(targetCurve, time);
Expand Down
5 changes: 4 additions & 1 deletion Editor/Mono/AssemblyInfo/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
[assembly: InternalsVisibleTo("Unity.Burst.Editor")]
[assembly: InternalsVisibleTo("Unity.CollabProxy.Editor")]
[assembly: InternalsVisibleTo("Unity.CollabProxy.EditorTests")]
[assembly: InternalsVisibleTo("Unity.CollabProxy.UI")]
[assembly: InternalsVisibleTo("Unity.CollabProxy.UI.Tests")]
[assembly: InternalsVisibleTo("Unity.CollabProxy.Client")]
[assembly: InternalsVisibleTo("Unity.CollabProxy.Client.Tests")]
[assembly: InternalsVisibleTo("UnityEditor.Advertisements")]
[assembly: InternalsVisibleTo("Unity.PackageManager")]
[assembly: InternalsVisibleTo("Unity.PackageManagerStandalone")]
Expand Down Expand Up @@ -88,6 +92,5 @@
[assembly: InternalsVisibleTo("Unity.InternalAPIEditorBridgeDev.003")]
[assembly: InternalsVisibleTo("Unity.InternalAPIEditorBridgeDev.004")]
[assembly: InternalsVisibleTo("Unity.InternalAPIEditorBridgeDev.005")]
[assembly: InternalsVisibleTo("com.unity.editor.resources-testable")]

[assembly: AssemblyIsEditorAssembly]
9 changes: 0 additions & 9 deletions Editor/Mono/AssetStore/AssetStoreInstaBuyWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ static public AssetStoreInstaBuyWindow ShowAssetStoreInstaBuyWindow(AssetStoreAs
w.m_PaymentMethodCard = paymentMethodCard;
w.m_PaymentMethodExpire = paymentMethodExpire;
w.m_PriceText = priceText;
UsabilityAnalytics.Track(string.Format("/AssetStore/ShowInstaBuy/{0}/{1}", w.m_Asset.packageID, w.m_Asset.id));
return w;
}

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

private static GUIContent s_AssetStoreLogo;
Expand Down Expand Up @@ -218,15 +216,13 @@ void PasswordGUI()
if (GUILayout.Button("Just put to basket..."))
{
AssetStore.Open(string.Format("content/{0}/basketpurchase", m_Asset.packageID));
UsabilityAnalytics.Track(string.Format("/AssetStore/PutToBasket/{0}/{1}", m_Asset.packageID, m_Asset.id));
m_Asset = null;
this.Close();
GUIUtility.ExitGUI();
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Cancel"))
{
UsabilityAnalytics.Track(string.Format("/AssetStore/CancelInstaBuy/{0}/{1}", m_Asset.packageID, m_Asset.id));
m_Asset = null;
this.Close();
GUIUtility.ExitGUI();
Expand Down Expand Up @@ -273,14 +269,12 @@ void PurchaseSuccessGUI()
GUILayout.FlexibleSpace();
if (GUILayout.Button("Close"))
{
UsabilityAnalytics.Track(string.Format("/AssetStore/PurchaseOk/{0}/{1}", m_Asset.packageID, m_Asset.id));
m_Asset = null;
this.Close();
}
GUILayout.Space(5);
if (GUILayout.Button("Import package"))
{
UsabilityAnalytics.Track(string.Format("/AssetStore/PurchaseOkImport/{0}/{1}", m_Asset.packageID, m_Asset.id));
m_BuildAttempts = 1;
m_Asset.previewInfo.buildProgress = 0f;
m_Purchasing = PurchaseStatus.StartBuild;
Expand Down Expand Up @@ -361,15 +355,13 @@ void PurchaseDeclinedGUI()
GUILayout.FlexibleSpace();
if (GUILayout.Button("Close"))
{
UsabilityAnalytics.Track(string.Format("/AssetStore/DeclinedAbort/{0}/{1}", m_Asset.packageID, m_Asset.id));
m_Asset = null;
Close();
}
GUILayout.Space(5);
if (GUILayout.Button("Put to basket"))
{
AssetStore.Open(string.Format("content/{0}/basketpurchase", m_Asset.packageID));
UsabilityAnalytics.Track(string.Format("/AssetStore/DeclinedPutToBasket/{0}/{1}", m_Asset.packageID, m_Asset.id));
m_Asset = null;
Close();
}
Expand Down Expand Up @@ -434,7 +426,6 @@ void CompletePurchase()
EditorUtility.DisplayDialog("Purchase failed", msg + " This purchase has been cancelled.",
"Add this item to basket", "Cancel");
});
UsabilityAnalytics.Track(string.Format("/AssetStore/InstaBuy/{0}/{1}", m_Asset.packageID, m_Asset.id));
}

void BuildPackage()
Expand Down
1 change: 0 additions & 1 deletion Editor/Mono/AssetStore/AssetStoreLoginWIndow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ static public void ShowAssetStoreLoginWindow(string loginReason, LoginCallback c
w.m_LoginCallback = callback;
w.m_LoginReason = loginReason;
w.m_LoginRemoteMessage = null;
UsabilityAnalytics.Track("/AssetStore/Login");
}

static GUIContent s_AssetStoreLogo;
Expand Down
67 changes: 11 additions & 56 deletions Editor/Mono/Audio/Mixer/GUI/AudioMixerDrawUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,26 @@ public static Color GetEffectColor(AudioMixerEffectController effect)

public class Styles
{
public GUIStyle headerStyle = new GUIStyle(EditorStyles.boldLabel);
public GUIStyle reorderableListLabel = new GUIStyle("PR Label");
public GUIStyle headerStyle = GetStyle("AM HeaderStyle");
public GUIStyle reorderableListLabel = GetStyle("ReorderableList");
public GUIStyle regionBg = GetStyle("RegionBg");
public GUIStyle channelStripVUMeterBg = GetStyle("ChannelStripVUMeterBg");
public GUIStyle channelStripAreaBackground = "CurveEditorBackground"; //"flow background";
public GUIStyle channelStripAreaBackground = GetStyle("CurveEditorBackground"); //"flow background";
public GUIStyle channelStripBg = GetStyle("ChannelStripBg");
public GUIStyle duckingMarker = GetStyle("ChannelStripDuckingMarker");
public GUIStyle channelStripAttenuationMarkerSquare = GetStyle("ChannelStripAttenuationMarkerSquare");
public GUIStyle channelStripHeaderStyle;
public GUIStyle channelStripHeaderStyle = GetStyle("AM ChannelStripHeaderStyle");
public GUIStyle soloToggle = GetStyle("SoloToggle");
public GUIStyle muteToggle = GetStyle("MuteToggle");
public GUIStyle bypassToggle = GetStyle("BypassToggle");
public GUIStyle circularToggle = GetStyle("CircularToggle");
public GUIStyle totalVULevel = new GUIStyle(EditorStyles.label);
public GUIStyle attenuationBar = "ChannelStripAttenuationBar";
public GUIStyle effectBar = "ChannelStripEffectBar";
public GUIStyle sendReturnBar = "ChannelStripSendReturnBar";
public GUIStyle effectName = new GUIStyle(EditorStyles.miniLabel);
public GUIStyle vuValue = new GUIStyle(EditorStyles.miniLabel);
public GUIStyle mixerHeader = new GUIStyle(EditorStyles.largeLabel);
public GUIStyle totalVULevel = GetStyle("AM TotalVuLabel");
public GUIStyle attenuationBar = GetStyle("ChannelStripAttenuationBar");
public GUIStyle effectBar = GetStyle("ChannelStripEffectBar");
public GUIStyle sendReturnBar = GetStyle("ChannelStripSendReturnBar");
public GUIStyle effectName = GetStyle("AM EffectName");
public GUIStyle vuValue = GetStyle("AM VuValue");
public GUIStyle mixerHeader = GetStyle("AM MixerHeader2");
public GUIStyle warningOverlay = GetStyle("WarningOverlay");
public Texture2D scrollShadowTexture = EditorGUIUtility.FindTexture("ScrollShadow");
public Texture2D leftToRightShadowTexture = EditorGUIUtility.FindTexture("LeftToRightShadow");
Expand All @@ -92,52 +92,7 @@ static GUIStyle GetStyle(string styleName)

public Styles()
{
headerStyle.alignment = TextAnchor.MiddleLeft;

Texture2D transparent = reorderableListLabel.hover.background;
reorderableListLabel.normal.background = transparent;
reorderableListLabel.active.background = transparent;
reorderableListLabel.focused.background = transparent;
reorderableListLabel.onNormal.background = transparent;
reorderableListLabel.onHover.background = transparent;
reorderableListLabel.onActive.background = transparent;
reorderableListLabel.onFocused.background = transparent;
reorderableListLabel.padding.left = reorderableListLabel.padding.right = 0;
reorderableListLabel.alignment = TextAnchor.MiddleLeft;

scrollShadowTexture = EditorGUIUtility.FindTexture("ScrollShadow");

channelStripHeaderStyle = new GUIStyle(EditorStyles.boldLabel);
channelStripHeaderStyle.alignment = TextAnchor.MiddleLeft;
channelStripHeaderStyle.fontSize = 11;
channelStripHeaderStyle.fontStyle = FontStyle.Bold;
channelStripHeaderStyle.wordWrap = false;
channelStripHeaderStyle.clipping = TextClipping.Clip;
channelStripHeaderStyle.padding = new RectOffset(4, 4, 4, 4);

totalVULevel.alignment = TextAnchor.MiddleRight;
totalVULevel.padding.right = 20;

effectName.padding.left = 4;
effectName.padding.top = 2;

vuValue.padding.left = 4;
vuValue.padding.right = 4;
vuValue.padding.top = 0;
vuValue.alignment = TextAnchor.MiddleRight;
vuValue.clipping = TextClipping.Overflow;

warningOverlay.alignment = TextAnchor.MiddleCenter;

mixerHeader.fontStyle = FontStyle.Bold;
mixerHeader.fontSize = 17;
mixerHeader.margin = new RectOffset();
mixerHeader.padding = new RectOffset();
mixerHeader.alignment = TextAnchor.UpperLeft;
if (EditorGUIUtility.isProSkin)
mixerHeader.normal.textColor = new Color(0.7f, 0.7f, 0.7f, 1.0f);
else
mixerHeader.normal.textColor = new Color(0.2f, 0.2f, 0.2f, 1.0f);
}
}
static Styles s_Styles;
Expand Down
18 changes: 3 additions & 15 deletions Editor/Mono/Audio/Mixer/GUI/AudioMixerWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ class GUIContents
public GUIContent infoText;
public GUIContent selectAudioMixer;
public GUIContent output;
public GUIStyle toolbarObjectField = new GUIStyle("ShurikenObjectField");
public GUIStyle toolbarLabel = new GUIStyle(EditorStyles.miniLabel);
public GUIStyle mixerHeader = new GUIStyle(EditorStyles.largeLabel);
public GUIStyle toolbarObjectField = "AM ToolbarObjectField";
public GUIStyle toolbarLabel = "AM ToolbarLabel";
public GUIStyle mixerHeader = "AM MixerHeader";

public GUIContents()
{
Expand All @@ -124,18 +124,6 @@ public GUIContents()
infoText = EditorGUIUtility.TrTextContent("Create an AudioMixer asset from the Project Browser to get started");
selectAudioMixer = EditorGUIUtility.TrTextContent("", "Select an Audio Mixer");
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.");
toolbarLabel.alignment = TextAnchor.MiddleLeft;
toolbarObjectField.normal.textColor = toolbarLabel.normal.textColor;

mixerHeader.fontStyle = FontStyle.Bold;
mixerHeader.fontSize = 17;
mixerHeader.margin = new RectOffset();
mixerHeader.padding = new RectOffset();
mixerHeader.alignment = TextAnchor.MiddleLeft;
if (!EditorGUIUtility.isProSkin)
mixerHeader.normal.textColor = new Color(0.4f, 0.4f, 0.4f, 1.0f);
else
mixerHeader.normal.textColor = new Color(0.7f, 0.7f, 0.7f, 1.0f);
}
}
private static GUIContents s_GuiContents;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,8 @@ public class State

public class Styles
{
public GUIStyle reorderableListLabel = new GUIStyle("PR Label");
public GUIStyle reorderableListLabelRightAligned;

public Styles()
{
Texture2D transparent = reorderableListLabel.hover.background;
reorderableListLabel.normal.background = transparent;
reorderableListLabel.active.background = transparent;
reorderableListLabel.focused.background = transparent;
reorderableListLabel.onNormal.background = transparent;
reorderableListLabel.onHover.background = transparent;
reorderableListLabel.onActive.background = transparent;
reorderableListLabel.onFocused.background = transparent;
reorderableListLabel.padding.left = reorderableListLabel.padding.right = 0;
reorderableListLabel.alignment = TextAnchor.MiddleLeft;

reorderableListLabelRightAligned = new GUIStyle(reorderableListLabel);
reorderableListLabelRightAligned.alignment = TextAnchor.MiddleRight;
reorderableListLabelRightAligned.clipping = TextClipping.Overflow;
}
public GUIStyle reorderableListLabel = "ReorderableList";
public GUIStyle reorderableListLabelRightAligned = "ReorderableListRightAligned";
}
static Styles s_Styles;

Expand Down
Loading

0 comments on commit 0f8d03f

Please sign in to comment.