Skip to content

Commit 6ce8f05

Browse files
author
Unity Technologies
committed
Unity 2019.3.0b11 C# reference source code
1 parent 044f335 commit 6ce8f05

File tree

48 files changed

+993
-261
lines changed

Some content is hidden

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

48 files changed

+993
-261
lines changed

Editor/Mono/Animation/AnimationUtility.bindings.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,19 +242,19 @@ private static void Internal_InvokeOnCurveWasModified(AnimationClip clip, Editor
242242

243243
extern internal static void UpdateTangentsFromMode([NotNull] AnimationCurve curve);
244244

245-
[NativeThrows]
245+
[NativeThrows, ThreadSafe]
246246
extern public static TangentMode GetKeyLeftTangentMode([NotNull] AnimationCurve curve, int index);
247247

248-
[NativeThrows]
248+
[NativeThrows, ThreadSafe]
249249
extern public static TangentMode GetKeyRightTangentMode([NotNull] AnimationCurve curve, int index);
250250

251251
[NativeThrows]
252252
extern public static bool GetKeyBroken([NotNull] AnimationCurve curve, int index);
253253

254-
[NativeThrows]
254+
[NativeThrows, ThreadSafe]
255255
extern public static void SetKeyLeftTangentMode([NotNull] AnimationCurve curve, int index, TangentMode tangentMode);
256256

257-
[NativeThrows]
257+
[NativeThrows, ThreadSafe]
258258
extern public static void SetKeyRightTangentMode([NotNull] AnimationCurve curve, int index, TangentMode tangentMode);
259259

260260
[NativeThrows]

Editor/Mono/Animation/ZoomableArea.cs

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,20 @@ private Rect shownAreaInsideMarginsInternal
518518
}
519519
}
520520

521+
float GetWidthInsideMargins(float widthWithMargins, bool substractSliderWidth = false)
522+
{
523+
float width = (widthWithMargins < kMinWidth) ? kMinWidth : widthWithMargins;
524+
float widthInsideMargins = width - leftmargin - rightmargin - (substractSliderWidth ? (m_VSlider ? styles.visualSliderWidth : 0) : 0);
525+
return Mathf.Max(widthInsideMargins, kMinWidth);
526+
}
527+
528+
float GetHeightInsideMargins(float heightWithMargins, bool substractSliderHeight = false)
529+
{
530+
float height = (heightWithMargins < kMinHeight) ? kMinHeight : heightWithMargins;
531+
float heightInsideMargins = height - topmargin - bottommargin - (substractSliderHeight ? (m_HSlider ? styles.visualSliderWidth : 0) : 0);
532+
return Mathf.Max(heightInsideMargins, kMinHeight);
533+
}
534+
521535
public virtual Bounds drawingBounds
522536
{
523537
get
@@ -920,45 +934,38 @@ public void EnforceScaleAndRange()
920934
return;
921935

922936
float epsilon = 0.00001f;
937+
float minChange = 0.01f;
923938

924-
if (newArea.width < oldArea.width - epsilon)
925-
{
926-
float xLerp = Mathf.InverseLerp(oldArea.width, newArea.width, rect.width / m_HScaleMax);
927-
newArea = new Rect(
928-
Mathf.Lerp(oldArea.x, newArea.x, xLerp),
929-
newArea.y,
930-
Mathf.Lerp(oldArea.width, newArea.width, xLerp),
931-
newArea.height
932-
);
933-
}
934-
if (newArea.height < oldArea.height - epsilon)
935-
{
936-
float yLerp = Mathf.InverseLerp(oldArea.height, newArea.height, rect.height / m_VScaleMax);
937-
newArea = new Rect(
938-
newArea.x,
939-
Mathf.Lerp(oldArea.y, newArea.y, yLerp),
940-
newArea.width,
941-
Mathf.Lerp(oldArea.height, newArea.height, yLerp)
942-
);
943-
}
944-
if (newArea.width > oldArea.width + epsilon)
939+
if (!Mathf.Approximately(newArea.width, oldArea.width))
945940
{
946-
float xLerp = Mathf.InverseLerp(oldArea.width, newArea.width, constrainedHScaleMin);
941+
float constrainedValue = newArea.width < oldArea.width - epsilon ? rect.width / m_HScaleMax : constrainedHScaleMin;
942+
constrainedValue = GetWidthInsideMargins(constrainedValue, true);
943+
float xLerp = Mathf.InverseLerp(oldArea.width, newArea.width, constrainedValue);
944+
float newWidth = Mathf.Lerp(oldArea.width, newArea.width, xLerp);
945+
float widthChange = Mathf.Abs(newWidth - newArea.width);
947946
newArea = new Rect(
948-
Mathf.Lerp(oldArea.x, newArea.x, xLerp),
947+
// only affect the position if there was any significant change in width (the unit is in pixels so technically anything under 0.05f would already be impossible to see)
948+
// this fixes an issue where if width was only different due to rounding issues, position changes are ignored as xLerp comes back 0 (or very nearly 0)
949+
widthChange > minChange ? Mathf.Lerp(oldArea.x, newArea.x, xLerp) : newArea.x,
949950
newArea.y,
950-
Mathf.Lerp(oldArea.width, newArea.width, xLerp),
951+
newWidth,
951952
newArea.height
952953
);
953954
}
954-
if (newArea.height > oldArea.height + epsilon)
955+
if (!Mathf.Approximately(newArea.height, oldArea.height))
955956
{
956-
float yLerp = Mathf.InverseLerp(oldArea.height, newArea.height, constrainedVScaleMin);
957+
float constrainedValue = newArea.height < oldArea.height - epsilon ? rect.height / m_VScaleMax : constrainedVScaleMin;
958+
constrainedValue = GetHeightInsideMargins(constrainedValue, true);
959+
float yLerp = Mathf.InverseLerp(oldArea.height, newArea.height, constrainedValue);
960+
float newHeight = Mathf.Lerp(oldArea.height, newArea.height, yLerp);
961+
float heightChange = Mathf.Abs(newHeight - newArea.height);
957962
newArea = new Rect(
958963
newArea.x,
959-
Mathf.Lerp(oldArea.y, newArea.y, yLerp),
964+
// only affect the position if there was any significant change in height (the unit is in pixels so technically anything under 0.05f would already be impossible to see)
965+
// this fixes an issue where if height was only different due to rounding issues, position changes are ignored as yLerp comes back 0 (or very nearly 0)
966+
heightChange > minChange ? Mathf.Lerp(oldArea.y, newArea.y, yLerp) : newArea.y,
960967
newArea.width,
961-
Mathf.Lerp(oldArea.height, newArea.height, yLerp)
968+
newHeight
962969
);
963970
}
964971

Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ private void CopyNativePlugins(BuildPostProcessArgs args, out List<string> cppPl
176176

177177
if (isDirectory)
178178
{
179-
FileUtil.CopyDirectoryRecursive(imp.assetPath, finalDestinationPath);
179+
// Since we may be copying from Assets make sure to not include .meta files to the build
180+
FileUtil.CopyDirectoryRecursive(imp.assetPath, finalDestinationPath, overwrite: false, ignoreMeta: true);
180181
}
181182
else
182183
{

Editor/Mono/CodeEditor/CodeEditor.cs

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22
// Copyright (c) Unity Technologies. For terms of use, see
33
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
44

5-
using System;
65
using System.Collections.Generic;
76
using System.IO;
87
using System.Linq;
9-
using System.Reflection;
108
using System.Text;
119
using UnityEditor;
1210
using UnityEditor.Callbacks;
13-
using UnityEditor.PlatformSupport;
1411
using UnityEditorInternal;
1512
using UnityEngine;
1613
using UnityEngine.Scripting;
@@ -22,6 +19,7 @@ public class CodeEditor
2219
internal static CodeEditor Editor { get; } = new CodeEditor();
2320
List<IExternalCodeEditor> m_ExternalCodeEditors = new List<IExternalCodeEditor>();
2421
IExternalCodeEditor m_DefaultEditor = new DefaultExternalCodeEditor();
22+
internal const string SystemDefaultPath = "";
2523

2624
public struct Installation
2725
{
@@ -60,13 +58,20 @@ internal Installation EditorInstallation
6058
{
6159
get
6260
{
63-
var editorPath = EditorPrefs.GetString("kScriptsDefaultApp");
64-
if (string.IsNullOrEmpty(editorPath))
61+
var editorPath = CurrentEditorInstallation.Trim();
62+
if (editorPath == CodeEditor.SystemDefaultPath)
6563
{
64+
// If no script editor is set, try to use first found supported one.
65+
var editorPaths = GetFoundScriptEditorPaths();
66+
if (editorPaths.Count > 0)
67+
{
68+
return new Installation { Path = editorPaths.Keys.First() };
69+
}
70+
6671
return new Installation
6772
{
6873
Name = "Internal",
69-
Path = "",
74+
Path = editorPath,
7075
};
7176
}
7277

@@ -79,26 +84,16 @@ internal Installation EditorInstallation
7984
}
8085
}
8186

82-
// This is supporting legacy script editors until they are moved to packages
83-
if (!string.IsNullOrEmpty(editorPath))
84-
return new Installation { Path = editorPath };
85-
86-
// If no script editor is set, try to use first found supported one.
87-
var editorPaths = GetFoundScriptEditorPaths();
88-
89-
if (editorPaths.Count > 0)
90-
return new Installation { Path = editorPaths.Keys.ToArray()[0] };
91-
92-
return new Installation();
87+
return new Installation { Path = editorPath };
9388
}
9489
}
9590

9691
internal IExternalCodeEditor Current
9792
{
9893
get
9994
{
100-
var editorPath = EditorPrefs.GetString("kScriptsDefaultApp");
101-
if (string.IsNullOrEmpty(editorPath))
95+
var editorPath = CurrentEditorInstallation.Trim();
96+
if (editorPath == CodeEditor.SystemDefaultPath)
10297
{
10398
return m_DefaultEditor;
10499
}
@@ -154,7 +149,7 @@ public static void Unregister(IExternalCodeEditor externalCodeEditor)
154149

155150
public static IExternalCodeEditor CurrentEditor => Editor.Current;
156151

157-
public static string CurrentEditorInstallation => Editor.EditorInstallation.Path;
152+
public static string CurrentEditorInstallation => EditorPrefs.GetString("kScriptsDefaultApp");
158153

159154
public static bool OSOpenFile(string appPath, string arguments)
160155
{

Editor/Mono/CodeEditor/DefaultExternalCodeEditor.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,12 @@ public bool OpenProject(string path, int line, int column)
128128
return false;
129129
}
130130

131-
string applicationPath = EditorPrefs.GetString("kScriptsDefaultApp");
132-
if (string.IsNullOrEmpty(applicationPath.Trim()))
131+
string applicationPath = CodeEditor.CurrentEditorInstallation.Trim();
132+
if (applicationPath == CodeEditor.SystemDefaultPath)
133133
{
134134
return false;
135135
}
136136

137-
138137
if (IsOSX)
139138
{
140139
return CodeEditor.OSOpenFile(applicationPath, CodeEditor.ParseArgument(Arguments, path, line, column));
@@ -145,7 +144,7 @@ public bool OpenProject(string path, int line, int column)
145144
StartInfo = new ProcessStartInfo
146145
{
147146
FileName = applicationPath,
148-
Arguments = string.IsNullOrEmpty(applicationPath) ? "" : CodeEditor.ParseArgument(Arguments, path, line, column),
147+
Arguments = CodeEditor.ParseArgument(Arguments, path, line, column),
149148
WindowStyle = ProcessWindowStyle.Hidden,
150149
CreateNoWindow = true,
151150
UseShellExecute = true,

Editor/Mono/GUI/TreeView/TreeViewControl/TreeViewControl.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ protected GetNewSelectionFunction getNewSelectionOverride
2929
set { m_TreeView.getNewSelectionOverride = (x, y, z) => value(x, y, z); }
3030
}
3131

32+
internal bool deselectOnUnhandledMouseDown
33+
{
34+
set
35+
{
36+
if (m_TreeView != null)
37+
m_TreeView.deselectOnUnhandledMouseDown = value;
38+
}
39+
}
40+
3241
TreeViewController m_TreeView;
3342
TreeViewControlDataSource m_DataSource;
3443
TreeViewControlGUI m_GUI;

Editor/Mono/Inspector/EditorElement.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,15 @@ internal void Reinit(int editorIndex)
132132

133133
private void UpdateInspectorVisibility()
134134
{
135-
if (!editor.CanBeExpandedViaAFoldout())
135+
if (editor.CanBeExpandedViaAFoldout())
136136
{
137-
SetElementVisible(m_InspectorElement, false);
137+
m_Footer.style.marginTop = 0;
138+
m_InspectorElement.style.paddingBottom = InspectorWindow.kEditorElementPaddingBottom;
138139
}
139140
else
140141
{
141-
SetElementVisible(m_InspectorElement, true);
142+
m_Footer.style.marginTop = -kFooterDefaultHeight;
143+
m_InspectorElement.style.paddingBottom = 0;
142144
}
143145
}
144146

@@ -222,15 +224,13 @@ void HeaderOnGUI()
222224
InvalidateIMGUILayouts(this);
223225
}
224226

225-
wasVisible = wasVisible && editor.CanBeExpandedViaAFoldout();
226-
227227
if (wasVisible != IsElementVisible(m_InspectorElement))
228228
{
229229
SetElementVisible(m_InspectorElement, wasVisible);
230-
231-
m_Footer.style.marginTop = wasVisible ? 0 : -kFooterDefaultHeight;
232230
}
233231

232+
UpdateInspectorVisibility();
233+
234234
var multiEditingSupported = inspectorWindow.IsMultiEditingSupported(editor, target);
235235

236236
if (!multiEditingSupported && wasVisible)

Editor/Mono/Inspector/InspectorElement.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ private VisualElement CreateIMGUIInspectorFromEditor(SerializedObject serialized
483483

484484
var originalWideMode = SetWideModeForWidth(inspector);
485485

486-
GUIStyle editorWrapper = (editor.UseDefaultMargins()
486+
GUIStyle editorWrapper = (editor.UseDefaultMargins() && editor.CanBeExpandedViaAFoldout()
487487
? EditorStyles.inspectorDefaultMargins
488488
: GUIStyle.none);
489489
try

Editor/Mono/Inspector/PlayerSettingsEditor/PlayerSettingsEditor.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ void OnEnable()
486486
m_RequireES31AEP = FindPropertyAssert("openGLRequireES31AEP");
487487
m_RequireES32 = FindPropertyAssert("openGLRequireES32");
488488

489-
m_LegacyClampBlendShapeWeights = FindPropertyAssert("legacyClampBlendShapeWeights");
489+
m_LegacyClampBlendShapeWeights = FindPropertyAssert("legacyClampBlendShapeWeights");
490490

491491
m_SettingsExtensions = new ISettingEditorExtension[validPlatforms.Length];
492492
for (int i = 0; i < validPlatforms.Length; i++)
@@ -1495,7 +1495,10 @@ private void OtherSectionRenderingGUI(BuildPlatform platform, BuildTargetGroup t
14951495
}
14961496

14971497
// Graphics APIs
1498-
GraphicsAPIsGUI(targetGroup, platform.defaultTarget);
1498+
using (new EditorGUI.DisabledScope(EditorApplication.isPlaying))
1499+
{
1500+
GraphicsAPIsGUI(targetGroup, platform.defaultTarget);
1501+
}
14991502

15001503
// Output color spaces
15011504
ColorGamutGUI(targetGroup);

0 commit comments

Comments
 (0)