Skip to content

Commit d09d3f5

Browse files
author
Unity Technologies
committed
Unity 2020.1.0a18 C# reference source code
1 parent 5bc2902 commit d09d3f5

File tree

88 files changed

+2900
-463
lines changed

Some content is hidden

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

88 files changed

+2900
-463
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
44

55
using System.Collections.Generic;
6-
using System.Diagnostics;
76
using UnityEngine;
87
using UnityEngine.Experimental.Rendering;
9-
using UnityEditor.Experimental.AssetImporters;
108
using UnityEngine.U2D;
119
using UnityEditor.Build;
1210
using UnityEditor.U2D.Common;
@@ -39,7 +37,6 @@ public override int DrawMaxSize(int defaultValue, bool isMixedValue, bool isDisa
3937

4038
class Styles
4139
{
42-
public readonly GUIStyle dropzoneStyle = "DropzoneStyle";
4340
public readonly GUIStyle preDropDown = "preDropDown";
4441
public readonly GUIStyle previewButton = "preButton";
4542
public readonly GUIStyle previewSlider = "preSlider";

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public override int DrawMaxSize(int defaultValue, bool isMixedValue, bool isDisa
3838

3939
class Styles
4040
{
41-
public readonly GUIStyle dropzoneStyle = "DropzoneStyle";
4241
public readonly GUIStyle preDropDown = "preDropDown";
4342
public readonly GUIStyle previewButton = "preButton";
4443
public readonly GUIStyle previewSlider = "preSlider";
@@ -60,7 +59,6 @@ class Styles
6059
public readonly GUIContent sRGBLabel = EditorGUIUtility.TrTextContent("sRGB", "Texture content is stored in gamma space.");
6160
public readonly GUIContent readWrite = EditorGUIUtility.TrTextContent("Read/Write Enabled", "Enable to be able to access the raw pixel data from code.");
6261
public readonly GUIContent variantMultiplierLabel = EditorGUIUtility.TrTextContent("Scale", "Down scale ratio.");
63-
public readonly GUIContent copyMasterButton = EditorGUIUtility.TrTextContent("Copy Master's Settings", "Copy all master's settings into this variant.");
6462
public readonly GUIContent packButton = EditorGUIUtility.TrTextContent("Pack Preview", "Pack this atlas.");
6563

6664
public readonly GUIContent disabledPackLabel = EditorGUIUtility.TrTextContent("Sprite Atlas packing is disabled. Enable it in Edit > Project Settings > Editor.", null, EditorGUIUtility.GetHelpIcon(MessageType.Info));

Editor/Mono/Animation/TimeArea.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public enum TimeFormat
4949
class Styles2
5050
{
5151
public GUIStyle timelineTick = "AnimationTimelineTick";
52-
public GUIStyle labelTickMarks = "CurveEditorLabelTickMarks";
5352
public GUIStyle playhead = "AnimationPlayHead";
5453
}
5554

Editor/Mono/AsyncProgressBar.bindings.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,11 @@ LayoutMode layoutMode
108108

109109
class GUIContents
110110
{
111-
public GUIContent rms;
112111
public GUIContent editSnapShots;
113-
public GUIContent infoText;
114-
public GUIContent selectAudioMixer;
115-
public GUIContent output;
116-
public GUIStyle toolbarObjectField = "AM ToolbarObjectField";
117-
public GUIStyle toolbarLabel = "AM ToolbarLabel";
118-
public GUIStyle mixerHeader = "AM MixerHeader";
119112

120113
public GUIContents()
121114
{
122-
rms = EditorGUIUtility.TrTextContent("RMS", "Switches between RMS (Root Mean Square) metering and peak metering. RMS is closer to the energy level and perceived loudness of the sound (hence lower than the peak meter), while peak-metering is useful for monitoring spikes in the signal that can cause clipping.");
123115
editSnapShots = EditorGUIUtility.TrTextContent("Edit in Play Mode", "Edit in playmode and your changes are automatically saved. Note when editing is disabled, live values are shown.", EditorGUIUtility.TrIconContent("Animation.Record", "Are scene and inspector changes recorded into the animation curves?").image);
124-
infoText = EditorGUIUtility.TrTextContent("Create an AudioMixer asset from the Project Browser to get started");
125-
selectAudioMixer = EditorGUIUtility.TrTextContent("", "Select an Audio Mixer");
126-
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.");
127116
}
128117
}
129118
private static GUIContents s_GuiContents;

Editor/Mono/BuildPlayerWindow.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,11 @@ class Styles
2929
public GUIContent invalidColorSpaceMessage = EditorGUIUtility.TrTextContent("In order to build a player, go to 'Player Settings...' to resolve the incompatibility between the Color Space and the current settings.", EditorGUIUtility.GetHelpIcon(MessageType.Warning));
3030
public GUIContent invalidLightmapEncodingMessage = EditorGUIUtility.TrTextContent("In order to build a player, go to 'Player Settings...' to resolve the incompatibility between the selected Lightmap Encoding and the current settings.", EditorGUIUtility.GetHelpIcon(MessageType.Warning));
3131
public GUIContent compilingMessage = EditorGUIUtility.TrTextContent("Cannot build player while editor is importing assets or compiling scripts.", EditorGUIUtility.GetHelpIcon(MessageType.Warning));
32-
public GUIStyle selected = "OL SelectedRow";
33-
public GUIStyle box = "OL Box";
3432
public GUIStyle title = EditorStyles.boldLabel;
3533
public GUIStyle evenRow = "CN EntryBackEven";
3634
public GUIStyle oddRow = "CN EntryBackOdd";
3735
public GUIStyle platformSelector = "PlayerSettingsPlatform";
38-
public GUIStyle toggle = "Toggle";
39-
public GUIStyle levelString = "PlayerSettingsLevel";
40-
public GUIStyle levelStringCounter = "RightAlignedLabel";
41-
public Vector2 toggleSize;
4236

43-
public GUIContent becauseYouAreNot = EditorGUIUtility.TrTextContent("Because you are not a member of this project this build will not access Unity services.", EditorGUIUtility.GetHelpIcon(MessageType.Warning));
44-
public GUIContent noSessionDialogText = EditorGUIUtility.TrTextContent("In order to publish your build to UDN, you need to sign in via the AssetStore and tick the 'Stay signed in' checkbox.");
4537
public GUIContent platformTitle = EditorGUIUtility.TrTextContent("Platform", "Which platform to build for");
4638
public GUIContent switchPlatform = EditorGUIUtility.TrTextContent("Switch Platform");
4739
public GUIContent build = EditorGUIUtility.TrTextContent("Build");
@@ -54,16 +46,12 @@ class Styles
5446
public string infoText = L10n.Tr("{0} is not included in your Unity Pro license. Your {0} build will include a Unity Personal Edition splash screen.\n\nYou must be eligible to use Unity Personal Edition to use this build option. Please refer to our EULA for further information.");
5547
public GUIContent eula = EditorGUIUtility.TrTextContent("Eula");
5648
public string addToYourPro = L10n.Tr("Add {0} to your Unity Pro license");
57-
public GUIContent useNativeCompilation = EditorGUIUtility.TrTextContent("Use native compilation (no Mono runtime)");
5849

5950
public Texture2D activePlatformIcon = EditorGUIUtility.IconContent("BuildSettings.SelectedIcon").image as Texture2D;
6051

6152
public const float kButtonWidth = 110;
6253

6354
public string shopURL = "https://store.unity3d.com/shop/";
64-
const string kDownloadURL = "http://unity3d.com/unity/download/";
65-
const string kMailURL = "http://unity3d.com/company/sales?type=sales";
66-
const string kPlatformInstallationURL = "https://unity3d.com/platform-installation";
6755

6856
public GUIContent GetDownloadErrorForTarget(BuildTarget target)
6957
{
@@ -76,7 +64,6 @@ public GUIContent GetDownloadErrorForTarget(BuildTarget target)
7664
public GUIContent autoconnectProfilerDisabled = EditorGUIUtility.TrTextContent("Autoconnect Profiler", "Profiling is only enabled in a Development Player.");
7765
public GUIContent buildWithDeepProfiler = EditorGUIUtility.TrTextContent("Deep Profiling Support", "Build Player with Deep Profiling Support. This might affect Player performance.");
7866
public GUIContent buildWithDeepProfilerDisabled = EditorGUIUtility.TrTextContent("Deep Profiling", "Profiling is only enabled in a Development Player.");
79-
public GUIContent vrRemoteStremaing = EditorGUIUtility.TrTextContent("VR Remote Streaming");
8067
public GUIContent allowDebugging = EditorGUIUtility.TrTextContent("Script Debugging");
8168
public GUIContent waitForManagedDebugger = EditorGUIUtility.TrTextContent("Wait For Managed Debugger", "Show a dialog where you can attach a managed debugger before any script execution.");
8269
public GUIContent explicitNullChecks = EditorGUIUtility.TrTextContent("Explicit Null Checks");
@@ -328,7 +315,6 @@ void OnGUI()
328315
if (styles == null)
329316
{
330317
styles = new Styles();
331-
styles.toggleSize = styles.toggle.CalcSize(new GUIContent("X"));
332318
}
333319

334320
if (!UnityConnect.instance.canBuildWithUPID)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Unity C# reference source
2+
// Copyright (c) Unity Technologies. For terms of use, see
3+
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4+
5+
using UnityEngine;
6+
7+
namespace UnityEditor
8+
{
9+
struct CameraProjectionCache
10+
{
11+
Matrix4x4 worldToClip;
12+
Rect viewport;
13+
float screen;
14+
15+
public CameraProjectionCache(Camera camera, float screenHeight)
16+
{
17+
worldToClip = camera.projectionMatrix * camera.worldToCameraMatrix;
18+
viewport = camera.pixelRect;
19+
screen = screenHeight;
20+
}
21+
22+
public Vector2 WorldToScreenPoint(Vector3 point)
23+
{
24+
Vector3 clip = worldToClip.MultiplyPoint(point);
25+
26+
return new Vector2(
27+
viewport.x + (1.0f + clip.x) * viewport.width * 0.5f,
28+
viewport.y + (1.0f + clip.y) * viewport.height * 0.5f);
29+
}
30+
31+
public Vector2 WorldToGUIPoint(Vector3 point)
32+
{
33+
return ScreenToGUIPoint(WorldToScreenPoint(point));
34+
}
35+
36+
public Vector2 GUIToScreenPoint(Vector2 point)
37+
{
38+
var pixels = EditorGUIUtility.PointsToPixels(point);
39+
pixels.y = screen - pixels.y;
40+
return pixels;
41+
}
42+
43+
public Vector2 ScreenToGUIPoint(Vector2 point)
44+
{
45+
point.y = screen - point.y;
46+
return GUIClip.Clip(EditorGUIUtility.PixelsToPoints(point));
47+
}
48+
}
49+
}

Editor/Mono/EditorGUI.cs

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5580,19 +5580,52 @@ internal static bool FoldoutInternal(Rect position, bool foldout, GUIContent con
55805580
// Make a progress bar.
55815581
public static void ProgressBar(Rect position, float value, string text)
55825582
{
5583+
ProgressBar(position, value, GUIContent.Temp(text), false, EditorStyles.progressBarBack, EditorStyles.progressBarBar, EditorStyles.progressBarText);
5584+
}
5585+
5586+
internal static bool ProgressBar(Rect position, float value, GUIContent content, bool textOnBar,
5587+
GUIStyle progressBarBackgroundStyle, GUIStyle progressBarStyle, GUIStyle progressBarTextStyle)
5588+
{
5589+
bool mouseHover = position.Contains(Event.current.mousePosition);
55835590
int id = GUIUtility.GetControlID(s_ProgressBarHash, FocusType.Keyboard, position);
55845591
Event evt = Event.current;
55855592
switch (evt.GetTypeForControl(id))
55865593
{
5594+
case EventType.MouseDown:
5595+
if (mouseHover)
5596+
{
5597+
Event.current.Use();
5598+
return true;
5599+
}
5600+
break;
55875601
case EventType.Repaint:
5588-
EditorStyles.progressBarBack.Draw(position, false, false, false, false);
5589-
Rect barRect = new Rect(position);
5590-
value = Mathf.Clamp01(value);
5591-
barRect.width *= value;
5592-
EditorStyles.progressBarBar.Draw(barRect, false, false, false, false);
5593-
EditorStyles.progressBarText.Draw(position, text, false, false, false, false);
5602+
progressBarBackgroundStyle.Draw(position, mouseHover, false, false, false);
5603+
if (value > 0.0f)
5604+
{
5605+
value = Mathf.Clamp01(value);
5606+
var barRect = new Rect(position);
5607+
barRect.width *= value;
5608+
if (barRect.width >= 1f)
5609+
progressBarStyle.Draw(barRect, textOnBar ? content : GUIContent.none, mouseHover, false, false, false);
5610+
}
5611+
else if (value == -1.0f)
5612+
{
5613+
float barWidth = position.width * 0.2f;
5614+
float halfBarWidth = barWidth / 2.0f;
5615+
float cos = Mathf.Cos((float)EditorApplication.timeSinceStartup * 2f);
5616+
float rb = position.x + halfBarWidth;
5617+
float re = position.xMax - halfBarWidth;
5618+
float scale = (re - rb) / 2f;
5619+
float cursor = scale * cos;
5620+
var barRect = new Rect(position.x + cursor + scale, position.y, barWidth, position.height);
5621+
progressBarStyle.Draw(barRect, GUIContent.none, mouseHover, false, false, false);
5622+
}
5623+
5624+
progressBarTextStyle.Draw(position, !textOnBar ? content : GUIContent.none, mouseHover, false, false, false);
55945625
break;
55955626
}
5627+
5628+
return false;
55965629
}
55975630

55985631
// Make a help box with a message to the user.

Editor/Mono/EditorSettings.bindings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ public static string webSecurityEmulationHostUrl
167167
[StaticAccessor("GetEditorSettings()", StaticAccessorType.Dot)]
168168
public static extern bool asyncShaderCompilation { get; set; }
169169

170+
[StaticAccessor("GetEditorSettings()", StaticAccessorType.Dot)]
171+
public static extern bool cachingShaderPreprocessor { get; set; }
172+
170173
public static string[] projectGenerationUserExtensions
171174
{
172175
get

Editor/Mono/EditorWindow.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public partial class EditorWindow : ScriptableObject
4848
public VisualElement rootVisualElement => this.GetRootVisualElement();
4949

5050
internal System.Object uiRootElement { get; set; }
51+
internal Action uiRootElementCreated { get; set; }
5152

5253
[HideInInspector]
5354
[SerializeField]
@@ -1139,6 +1140,7 @@ internal static VisualElement GetRootVisualElement(this EditorWindow window)
11391140
{
11401141
var root = CreateRoot();
11411142
window.uiRootElement = root;
1143+
window.uiRootElementCreated?.Invoke();
11421144
return root;
11431145
}
11441146

Editor/Mono/GUI/AboutWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public void OnGUI()
145145

146146
GUILayout.BeginHorizontal();
147147
GUILayout.Label(s_MonoLogo);
148-
GUILayout.Label("Scripting powered by The Mono Project.\n\n(c) 2011 Novell, Inc.", "MiniLabel", GUILayout.Width(200));
148+
GUILayout.Label("Scripting powered by The Mono Project.\n\n(c) 2011 Novell, Inc.", "MiniLabel", GUILayout.Width(210));
149149
GUILayout.Label(s_AgeiaLogo);
150150
GUILayout.Label("Physics powered by PhysX.\n\n(c) 2019 NVIDIA Corporation.", "MiniLabel", GUILayout.Width(200));
151151
GUILayout.EndHorizontal();

0 commit comments

Comments
 (0)