Skip to content

Commit 6a4ef27

Browse files
author
Unity Technologies
committed
Unity 2019.1.0a7 C# reference source code
1 parent b1dc88d commit 6a4ef27

145 files changed

Lines changed: 3530 additions & 1712 deletions

File tree

Some content is hidden

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

Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModuleBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ private void UndoCallback()
327327
protected static Rect ClampSpriteRect(Rect rect, float maxX, float maxY)
328328
{
329329
// Clamp rect to width height
330+
rect = FlipNegativeRect(rect);
330331
Rect newRect = new Rect();
331332

332333
newRect.xMin = Mathf.Clamp(rect.xMin, 0, maxX - 1);

Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModuleBaseView.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ private void RemoveMainUI(VisualElement mainView)
108108
mainView.UnregisterCallback<SpriteSelectionChangeEvent>(SelectionChange);
109109
}
110110

111+
private void UpdatePositionField(Rect rect)
112+
{
113+
m_PositionFieldX.SetValueWithoutNotify((long)selectedSpriteRect.x);
114+
m_PositionFieldY.SetValueWithoutNotify((long)selectedSpriteRect.y);
115+
m_PositionFieldW.SetValueWithoutNotify((long)selectedSpriteRect.width);
116+
m_PositionFieldH.SetValueWithoutNotify((long)selectedSpriteRect.height);
117+
}
118+
111119
private void AddMainUI(VisualElement mainView)
112120
{
113121
var visualTree = EditorGUIUtility.Load("UXML/SpriteEditor/SpriteFrameModuleInspector.uxml") as VisualTreeAsset;
@@ -141,7 +149,7 @@ private void AddMainUI(VisualElement mainView)
141149
var rect = selectedSpriteRect;
142150
rect.x = evt.newValue;
143151
selectedSpriteRect = rect;
144-
m_PositionFieldX.SetValueWithoutNotify((long)selectedSpriteRect.x);
152+
UpdatePositionField(selectedSpriteRect);
145153
}
146154
});
147155

@@ -153,7 +161,7 @@ private void AddMainUI(VisualElement mainView)
153161
var rect = selectedSpriteRect;
154162
rect.y = evt.newValue;
155163
selectedSpriteRect = rect;
156-
m_PositionFieldY.SetValueWithoutNotify((long)selectedSpriteRect.y);
164+
UpdatePositionField(selectedSpriteRect);
157165
}
158166
});
159167

@@ -165,7 +173,7 @@ private void AddMainUI(VisualElement mainView)
165173
var rect = selectedSpriteRect;
166174
rect.width = evt.newValue;
167175
selectedSpriteRect = rect;
168-
m_PositionFieldW.SetValueWithoutNotify((long)selectedSpriteRect.width);
176+
UpdatePositionField(selectedSpriteRect);
169177
}
170178
});
171179

@@ -177,7 +185,7 @@ private void AddMainUI(VisualElement mainView)
177185
var rect = selectedSpriteRect;
178186
rect.height = evt.newValue;
179187
selectedSpriteRect = rect;
180-
m_PositionFieldH.SetValueWithoutNotify((long)selectedSpriteRect.height);
188+
UpdatePositionField(selectedSpriteRect);
181189
}
182190
});
183191

Editor/Mono/Animation/AnimationWindow/CurveEditorWindow.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,9 @@ public void Show(Action<AnimationCurve> onCurveChanged, CurveEditorSettings sett
289289
internal class Styles
290290
{
291291
public GUIStyle curveEditorBackground = "PopupCurveEditorBackground";
292-
public GUIStyle miniToolbarPopup = "MiniToolbarPopup";
293292
public GUIStyle miniToolbarButton = "MiniToolbarButtonLeft";
294293
public GUIStyle curveSwatch = "PopupCurveEditorSwatch";
295294
public GUIStyle curveSwatchArea = "PopupCurveSwatchBackground";
296-
public GUIStyle curveWrapPopup = "PopupCurveDropdown";
297295
}
298296
internal static Styles ms_Styles;
299297

Editor/Mono/AssetPipeline/TextureImporterEnums.cs

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,29 +140,54 @@ public enum TextureImporterFormat
140140
ETC2_RGB4_PUNCHTHROUGH_ALPHA = 46,
141141
// ETC2 (GLES3.0) 8 bits/pixel compressed RGBA texture format.
142142
ETC2_RGBA8 = 47,
143-
// ASTC (block size 4x4) compressed RGB texture format.
143+
144+
// ASTC uses 128bit block of varying sizes (we use only square blocks). It does not distinguish RGB/RGBA
145+
ASTC_4x4 = 48,
146+
ASTC_5x5 = 49,
147+
ASTC_6x6 = 50,
148+
ASTC_8x8 = 51,
149+
ASTC_10x10 = 52,
150+
ASTC_12x12 = 53,
151+
152+
// please note that obsolete attrs are currently disabled because we have tests that checks for "no warnings"
153+
// yet at the same time there are packages that reference old ASTC enums.
154+
// hence the only way is to go to trunk -> fix packages -> obsolete
155+
156+
// [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
157+
// [System.Obsolete("Use ASTC_4x4 (UnityUpgradable) -> ASTC_4x4")]
144158
ASTC_RGB_4x4 = 48,
145-
// ASTC (block size 5x5) compressed RGB texture format.
159+
// [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
160+
// [System.Obsolete("Use ASTC_5x5 (UnityUpgradable) -> ASTC_5x5")]
146161
ASTC_RGB_5x5 = 49,
147-
// ASTC (block size 6x6) compressed RGB texture format.
162+
// [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
163+
// [System.Obsolete("Use ASTC_6x6 (UnityUpgradable) -> ASTC_6x6")]
148164
ASTC_RGB_6x6 = 50,
149-
// ASTC (block size 8x8) compressed RGB texture format.
165+
// [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
166+
// [System.Obsolete("Use ASTC_8x8 (UnityUpgradable) -> ASTC_8x8")]
150167
ASTC_RGB_8x8 = 51,
151-
// ASTC (block size 10x10) compressed RGB texture format.
168+
// [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
169+
// [System.Obsolete("Use ASTC_10x10 (UnityUpgradable) -> ASTC_10x10")]
152170
ASTC_RGB_10x10 = 52,
153-
// ASTC (block size 12x12) compressed RGB texture format.
171+
// [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
172+
// [System.Obsolete("Use ASTC_12x12 (UnityUpgradable) -> ASTC_12x12")]
154173
ASTC_RGB_12x12 = 53,
155-
// ASTC (block size 4x4) compressed RGBA texture format.
174+
// [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
175+
// [System.Obsolete("Use ASTC_4x4 (UnityUpgradable) -> ASTC_4x4")]
156176
ASTC_RGBA_4x4 = 54,
157-
// ASTC (block size 5x5) compressed RGBA texture format.
177+
// [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
178+
// [System.Obsolete("Use ASTC_5x5 (UnityUpgradable) -> ASTC_5x5")]
158179
ASTC_RGBA_5x5 = 55,
159-
// ASTC (block size 6x6) compressed RGBA texture format.
180+
// [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
181+
// [System.Obsolete("Use ASTC_6x6 (UnityUpgradable) -> ASTC_6x6")]
160182
ASTC_RGBA_6x6 = 56,
161-
// ASTC (block size 8x8) compressed RGBA texture format.
183+
// [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
184+
// [System.Obsolete("Use ASTC_8x8 (UnityUpgradable) -> ASTC_8x8")]
162185
ASTC_RGBA_8x8 = 57,
163-
// ASTC (block size 10x10) compressed RGBA texture format.
186+
// [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
187+
// [System.Obsolete("Use ASTC_10x10 (UnityUpgradable) -> ASTC_10x10")]
164188
ASTC_RGBA_10x10 = 58,
165-
// ASTC (block size 12x12) compressed RGBA texture format.
189+
// [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
190+
// [System.Obsolete("Use ASTC_12x12 (UnityUpgradable) -> ASTC_12x12")]
166191
ASTC_RGBA_12x12 = 59,
167192

168193
// Nintendo 3DS-flavoured ETC

Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,9 @@ protected static void RecordCommonFiles(BuildPostProcessArgs args, string variat
354354
// Mark all the managed DLLs in Data/Managed as engine API assemblies
355355
// Data/Managed may already contain managed DLLs in the UnityEngine.*.dll naming scheme from the extensions
356356
// So we find the files in the source Variations directory and mark the corresponding files in the output
357-
foreach (var file in Directory.GetFiles(Path.Combine(variationSourceFolder, "Data/Managed"), "*.dll"))
357+
var path = Path.Combine(variationSourceFolder, "Data/Managed");
358+
foreach (var file in Directory.GetFiles(path, "*.dll")
359+
.Concat(Directory.GetFiles(path, "*.dll.mdb")))
358360
{
359361
var filename = Path.GetFileName(file);
360362
if (!filename.StartsWith("UnityEngine"))

Editor/Mono/Commands/GOCreationCommands.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,14 @@ static void CreateParticleSystem(MenuCommand menuCommand)
244244
Place(go, parent);
245245
}
246246

247-
[MenuItem("GameObject/Effects/Trail", priority = 2)]
247+
[MenuItem("GameObject/Effects/Particle System Force Field", priority = 2)]
248+
static void CreateParticleSystemForceField(MenuCommand menuCommand)
249+
{
250+
var parent = menuCommand.context as GameObject;
251+
Place(ObjectFactory.CreateGameObject("Particle System Force Field", typeof(ParticleSystemForceField)), parent);
252+
}
253+
254+
[MenuItem("GameObject/Effects/Trail", priority = 3)]
248255
static void CreateTrail(MenuCommand menuCommand)
249256
{
250257
var parent = menuCommand.context as GameObject;
@@ -253,7 +260,7 @@ static void CreateTrail(MenuCommand menuCommand)
253260
Place(go, parent);
254261
}
255262

256-
[MenuItem("GameObject/Effects/Line", priority = 3)]
263+
[MenuItem("GameObject/Effects/Line", priority = 4)]
257264
static void CreateLine(MenuCommand menuCommand)
258265
{
259266
var parent = menuCommand.context as GameObject;

Editor/Mono/ConsoleWindow.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ internal class Constants
5353
public static readonly string CollapseLabel = L10n.Tr("Collapse");
5454
public static readonly string StopForAssertLabel = L10n.Tr("Stop for Assert");
5555
public static readonly string StopForErrorLabel = L10n.Tr("Stop for Error");
56+
public static readonly string ClearOnBuildLabel = L10n.Tr("Clear on Build");
5657

5758
public static int LogStyleLineCount
5859
{
@@ -223,6 +224,7 @@ enum ConsoleFlags
223224
LogLevelWarning = 1 << 8,
224225
LogLevelError = 1 << 9,
225226
ShowTimestamp = 1 << 10,
227+
ClearOnBuild = 1 << 11,
226228
};
227229

228230
static ConsoleWindow ms_ConsoleWindow = null;
@@ -567,6 +569,7 @@ void OnGUI()
567569
}
568570

569571
SetFlag(ConsoleFlags.ClearOnPlay, GUILayout.Toggle(HasFlag(ConsoleFlags.ClearOnPlay), Constants.ClearOnPlayLabel, Constants.MiniButton));
572+
SetFlag(ConsoleFlags.ClearOnBuild, GUILayout.Toggle(HasFlag(ConsoleFlags.ClearOnBuild), Constants.ClearOnBuildLabel, Constants.MiniButton));
570573
SetFlag(ConsoleFlags.ErrorPause, GUILayout.Toggle(HasFlag(ConsoleFlags.ErrorPause), Constants.ErrorPauseLabel, Constants.MiniButton));
571574

572575
ConnectionGUILayout.AttachToPlayerDropdown(m_ConsoleAttachToPlayerState, EditorStyles.toolbarDropDown);

Editor/Mono/ContainerWindow.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,13 @@ internal void ShowPopupWithMode(ShowMode mode)
8282
m_RootView.SetWindowRecurse(this);
8383
Internal_SetTitle(m_Title);
8484
Save();
85-
// only set focus iff mode is a popupMenu.
85+
// only set focus if mode is a popupMenu.
8686
Internal_BringLiveAfterCreation(false, mode == ShowMode.PopupMenu);
87+
88+
// Fit window to screen - needs to be done after bringing the window live
89+
position = FitWindowRectToScreen(m_PixelRect, true, false);
90+
rootView.position = new Rect(0, 0, m_PixelRect.width, m_PixelRect.height);
91+
rootView.Reflow();
8792
}
8893

8994
static Color skinBackgroundColor

Editor/Mono/EditorWindow.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,15 @@ internal void DrawNotification()
309309
warningSize.y = targetHeight;
310310

311311
Rect r = new Rect((position.width - warningSize.x) * .5f, 20 + (position.height - 20 - warningSize.y) * .7f, warningSize.x, warningSize.y);
312+
313+
// Round notification coordinate & with to integers, so that text
314+
// shadow rendering(which is offset from base text) gets exactly
315+
// the same floating point results for text wrapping. Without this,
316+
// it can lead to tiny differences that make shadow be word - wrapped
317+
// differently from foreground text.
318+
r.x = Mathf.FloorToInt(r.x);
319+
r.width = Mathf.FloorToInt(r.width);
320+
312321
double time = EditorApplication.timeSinceStartup;
313322
if (time > m_FadeoutTime)
314323
GUI.color = new Color(1, 1, 1, 1 - (float)((time - m_FadeoutTime) / kWarningFadeoutTime));

Editor/Mono/GUI/HexColorTextField.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,14 @@ internal static Color32 DoHexColorTextField(int id, Rect rect, Color32 color, bo
4747
if (EndChangeCheck())
4848
{
4949
s_RecycledEditor.text = s_RecycledEditor.text.ToUpper();
50+
if (newHex.Length > 0)
51+
{
52+
if (newHex[0] != '#')
53+
newHex = '#' + newHex;
54+
}
5055

5156
Color newColor;
52-
if (ColorUtility.TryParseHtmlString("#" + newHex, out newColor))
57+
if (ColorUtility.TryParseHtmlString(newHex, out newColor))
5358
color = new Color(newColor.r, newColor.g, newColor.b, showAlpha ? newColor.a : color.a);
5459
}
5560

0 commit comments

Comments
 (0)