Skip to content

Commit 522c96e

Browse files
author
Unity Technologies
committed
Unity 2019.1.7f1 C# reference source code
1 parent 69a7628 commit 522c96e

15 files changed

Lines changed: 155 additions & 85 deletions

File tree

Editor/Mono/AssetDatabase/AssetPreview.bindings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ internal static Texture2D GetAssetPreview(int instanceID)
3030
[FreeFunction("AssetPreviewBindings::GetAssetPreview")]
3131
internal static extern Texture2D GetAssetPreview(int instanceID, int clientID);
3232

33+
[FreeFunction("AssetPreviewBindings::HasAssetPreview")]
34+
internal static extern bool HasAssetPreview(int instanceID, int clientID);
35+
3336
public static bool IsLoadingAssetPreview(int instanceID)
3437
{
3538
return IsLoadingAssetPreview(instanceID, kSharedClientID);

Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ public override void UpdateBootConfig(BuildTarget target, BootConfigData config,
8181

8282
if (PlayerSettings.forceSingleInstance)
8383
config.AddKey("single-instance");
84+
if (!PlayerSettings.useFlipModelSwapchain)
85+
config.AddKey("force-d3d11-bltblt-mode");
8486
if (IL2CPPUtils.UseIl2CppCodegenWithMonoBackend(BuildPipeline.GetBuildTargetGroup(target)))
8587
config.Set("mono-codegen", "il2cpp");
8688
if ((options & BuildOptions.EnableHeadlessMode) != 0)

Editor/Mono/GUI/DockArea.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ protected override void AddDefaultItemsToMenu(GenericMenu menu, EditorWindow vie
685685
}
686686

687687
menu.AddSeparator("");
688-
menu.AddItem(EditorGUIUtility.TextContent("UIElements Debugger _%f5"), false, DebugWindow, view);
688+
AddUIElementsDebuggerToMenu(menu);
689689
}
690690

691691
void AddTabToHere(object userData)
@@ -1127,7 +1127,7 @@ protected override void AddDefaultItemsToMenu(GenericMenu menu, EditorWindow win
11271127
}
11281128

11291129
menu.AddSeparator("");
1130-
menu.AddItem(EditorGUIUtility.TextContent("UIElements Debugger _%f5"), false, DebugWindow, window);
1130+
AddUIElementsDebuggerToMenu(menu);
11311131
}
11321132
}
11331133
}

Editor/Mono/GameView/GameView.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ internal class GameView : EditorWindow, IHasCustomMenu, IGameViewSizeMenuUser
4444
const float kMinScale = 1f;
4545
const float kMaxScale = 5f;
4646
const float kScrollZoomSnapDelay = 0.2f;
47+
// This will save the previous state which will be useful in case of platform switch
48+
int prevSizeGroupType;
4749

4850
float minScale
4951
{
@@ -587,6 +589,13 @@ private void DoToolbarGUI()
587589
EditorGUILayout.GameViewSizePopup(currentSizeGroupType, selectedSizeIndex, this, EditorStyles.toolbarPopup, GUILayout.Width(160f));
588590

589591
DoZoomSlider();
592+
// If the previous platform and current does not match, update the scale
593+
if ((int)currentSizeGroupType != prevSizeGroupType)
594+
{
595+
UpdateZoomAreaAndParent();
596+
// Update the platform to the recent one
597+
prevSizeGroupType = (int)currentSizeGroupType;
598+
}
590599

591600
if (FrameDebuggerUtility.IsLocalEnabled())
592601
{

Editor/Mono/HostView.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
using System.Reflection;
88
using UnityEditor.UIElements.Debugger;
99
using UnityEngine.UIElements;
10+
using System.Linq;
11+
using UnityEditor.ShortcutManagement;
1012
using Unity.Experimental.EditorMode;
1113

1214
namespace UnityEditor
@@ -283,18 +285,6 @@ static class HostViewStyles
283285

284286
public void InvokeOnGUI(Rect onGUIPosition, Rect viewRect)
285287
{
286-
// Handle window reloading.
287-
if (Unsupported.IsDeveloperMode() &&
288-
actualView != null &&
289-
Event.current.type == EventType.KeyUp && Event.current.keyCode == KeyCode.F5)
290-
{
291-
if (Event.current.control)
292-
DebugWindow(actualView);
293-
else
294-
Reload(actualView);
295-
return;
296-
}
297-
298288
DoWindowDecorationStart();
299289

300290
BeginOffsetArea(viewRect, GUIContent.none, "TabWindowBackground");
@@ -543,15 +533,6 @@ private void Inspect(object userData)
543533
Selection.activeObject = (UnityEngine.Object)userData;
544534
}
545535

546-
internal void DebugWindow(object userData)
547-
{
548-
EditorWindow window = userData as EditorWindow;
549-
if (window == null)
550-
return;
551-
552-
UIElementsDebugger.OpenAndInspectWindow(window);
553-
}
554-
555536
internal void Reload(object userData)
556537
{
557538
EditorWindow window = userData as EditorWindow;
@@ -668,5 +649,24 @@ protected void ClearBackground()
668649
EditorGUIUtility.kViewBackgroundColor);
669650
backgroundValid = true;
670651
}
652+
653+
protected void AddUIElementsDebuggerToMenu(GenericMenu menu)
654+
{
655+
var itemContent = UIElementsDebugger.WindowName;
656+
var shortcut = ShortcutIntegration.instance.directory.FindShortcutEntry(UIElementsDebugger.k_WindowPath);
657+
if (shortcut != null && shortcut.combinations.Any())
658+
itemContent += $" {KeyCombination.SequenceToMenuString(shortcut.combinations)}";
659+
660+
menu.AddItem(EditorGUIUtility.TextContent(itemContent), false, DebugWindow, actualView);
661+
}
662+
663+
private void DebugWindow(object userData)
664+
{
665+
EditorWindow window = userData as EditorWindow;
666+
if (window == null)
667+
return;
668+
669+
UIElementsDebugger.OpenAndInspectWindow(window);
670+
}
671671
}
672672
}

Editor/Mono/Inspector/PlayerSettingsEditor/PlayerSettingsEditor.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ class SettingsContent
119119
public static readonly GUIContent displayResolutionDialogDeprecationWarning = EditorGUIUtility.TrTextContent("The Display Resolution Dialog has been deprecated and will be removed in a future version.");
120120
public static readonly GUIContent visibleInBackground = EditorGUIUtility.TrTextContent("Visible In Background");
121121
public static readonly GUIContent allowFullscreenSwitch = EditorGUIUtility.TrTextContent("Allow Fullscreen Switch");
122+
public static readonly GUIContent useFlipModelSwapChain = EditorGUIUtility.TrTextContent("Use DXGI Flip Model Swapchain for D3D11", "Flip model ensures the best performance. Disable this to fallback to Windows 7-style BltBlt model. This setting affects only D3D11 graphics API.");
122123
public static readonly GUIContent use32BitDisplayBuffer = EditorGUIUtility.TrTextContent("Use 32-bit Display Buffer*", "If set Display Buffer will be created to hold 32-bit color values. Use it only if you see banding, as it has performance implications.");
123124
public static readonly GUIContent disableDepthAndStencilBuffers = EditorGUIUtility.TrTextContent("Disable Depth and Stencil*");
124125
public static readonly GUIContent preserveFramebufferAlpha = EditorGUIUtility.TrTextContent("Render Over Native UI*", "Enable this option ONLY if you want Unity to render on top of the native Android or iOS UI.");
@@ -326,6 +327,7 @@ PlayerSettingsSplashScreenEditor splashScreenEditor
326327
SerializedProperty m_VisibleInBackground;
327328
SerializedProperty m_AllowFullscreenSwitch;
328329
SerializedProperty m_ForceSingleInstance;
330+
SerializedProperty m_UseFlipModelSwapchain;
329331

330332
SerializedProperty m_RunInBackground;
331333
SerializedProperty m_CaptureSingleScreen;
@@ -485,6 +487,7 @@ void OnEnable()
485487
m_SkinOnGPU = FindPropertyAssert("gpuSkinning");
486488
m_GraphicsJobs = FindPropertyAssert("graphicsJobs");
487489
m_ForceSingleInstance = FindPropertyAssert("forceSingleInstance");
490+
m_UseFlipModelSwapchain = FindPropertyAssert("useFlipModelSwapchain");
488491

489492
m_RequireES31 = FindPropertyAssert("openGLRequireES31");
490493
m_RequireES31AEP = FindPropertyAssert("openGLRequireES31AEP");
@@ -952,6 +955,7 @@ public void ResolutionSectionGUI(BuildTargetGroup targetGroup, ISettingEditorExt
952955
EditorGUILayout.PropertyField(m_AllowFullscreenSwitch, SettingsContent.allowFullscreenSwitch);
953956

954957
EditorGUILayout.PropertyField(m_ForceSingleInstance);
958+
EditorGUILayout.PropertyField(m_UseFlipModelSwapchain, SettingsContent.useFlipModelSwapChain);
955959
EditorGUILayout.PropertyField(m_SupportedAspectRatios, true);
956960

957961
EditorGUILayout.Space();

Editor/Mono/PlayerSettings.bindings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,8 @@ public static bool singlePassStereoRendering
523523
// Restrict standalone players to a single concurrent running instance.
524524
public static extern bool forceSingleInstance { get; set; }
525525

526+
public static extern bool useFlipModelSwapchain { get; set; }
527+
526528
[NativeProperty(TargetType = TargetType.Field)]
527529
public static extern bool openGLRequireES31
528530
{

Modules/ParticleSystemEditor/ParticleSystemUI.cs

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ internal class ParticleSystemUI
2020
private static string[] s_ModuleNames;
2121
private string m_SupportsCullingText;
2222
private string m_SupportsCullingTextLabel; // Cached version including bullet points
23+
private int m_CachedMeshInstanceID;
24+
private int m_CachedMaterialInstanceID;
25+
private int m_CachedMeshDirtyCount;
26+
private int m_CachedMaterialDirtyCount;
2327

2428
private static PrefColor s_BoundsColor = new PrefColor("Particle System/Bounds", 1.0f, 235.0f / 255.0f, 4.0f / 255.0f, 1.0f);
2529

@@ -203,23 +207,46 @@ public void OnGUI(float width, bool fixedWidth)
203207
if (isRepaintEvent && renderer != null)
204208
{
205209
bool iconRendered = false;
206-
int instanceID = 0;
207210

208211
if (!multiEdit)
209212
{
213+
int instanceID = 0;
214+
210215
if (renderer.renderMode == ParticleSystemRenderMode.Mesh)
211216
{
212217
if (renderer.mesh != null)
218+
{
213219
instanceID = renderer.mesh.GetInstanceID();
220+
221+
// If the asset is dirty we ensure to get a updated one by clearing cache of temporary previews
222+
if (m_CachedMeshInstanceID != instanceID)
223+
{
224+
m_CachedMeshInstanceID = instanceID;
225+
m_CachedMeshDirtyCount = -1;
226+
}
227+
if (EditorUtility.GetDirtyCount(instanceID) != m_CachedMeshDirtyCount)
228+
{
229+
AssetPreview.ClearTemporaryAssetPreviews();
230+
m_CachedMeshDirtyCount = EditorUtility.GetDirtyCount(instanceID);
231+
}
232+
}
214233
}
215234
else if (renderer.sharedMaterial != null)
216235
{
217236
instanceID = renderer.sharedMaterial.GetInstanceID();
218-
}
219237

220-
// If the asset is dirty we ensure to get a updated one by clearing cache of temporary previews
221-
if (EditorUtility.IsDirty(instanceID))
222-
AssetPreview.ClearTemporaryAssetPreviews();
238+
// If the asset is dirty we ensure to get a updated one by clearing cache of temporary previews
239+
if (m_CachedMaterialInstanceID != instanceID)
240+
{
241+
m_CachedMaterialInstanceID = instanceID;
242+
m_CachedMaterialDirtyCount = -1;
243+
}
244+
if (EditorUtility.GetDirtyCount(instanceID) != m_CachedMaterialDirtyCount)
245+
{
246+
AssetPreview.ClearTemporaryAssetPreviews();
247+
m_CachedMaterialDirtyCount = EditorUtility.GetDirtyCount(instanceID);
248+
}
249+
}
223250

224251
if (instanceID != 0)
225252
{

Modules/UIElements/StyleSheets/VisualElementStylesData.cs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -244,26 +244,27 @@ internal void ApplyRule(StyleSheet sheet, int specificity, StyleRule rule, Style
244244
if (handles[0].valueType == StyleValueType.Keyword && handles[0].valueIndex == (int)StyleValueKeyword.Initial)
245245
{
246246
ApplyInitialStyleValue(propertyID, specificity);
247-
return;
248247
}
249-
250-
switch (propertyID)
248+
else
251249
{
252-
case StylePropertyID.Unknown:
253-
break;
254-
case StylePropertyID.Custom:
255-
ApplyCustomStyleProperty(sheet, styleProperty, specificity);
256-
break;
257-
case StylePropertyID.BorderRadius:
258-
case StylePropertyID.BorderWidth:
259-
case StylePropertyID.Flex:
260-
case StylePropertyID.Margin:
261-
case StylePropertyID.Padding:
262-
ApplyShorthandProperty(sheet, propertyID, styleProperty.values, specificity);
263-
break;
264-
default:
265-
ApplyStyleProperty(s_StyleSheetApplicator, sheet, propertyID, handles, specificity);
266-
break;
250+
switch (propertyID)
251+
{
252+
case StylePropertyID.Unknown:
253+
break;
254+
case StylePropertyID.Custom:
255+
ApplyCustomStyleProperty(sheet, styleProperty, specificity);
256+
break;
257+
case StylePropertyID.BorderRadius:
258+
case StylePropertyID.BorderWidth:
259+
case StylePropertyID.Flex:
260+
case StylePropertyID.Margin:
261+
case StylePropertyID.Padding:
262+
ApplyShorthandProperty(sheet, propertyID, styleProperty.values, specificity);
263+
break;
264+
default:
265+
ApplyStyleProperty(s_StyleSheetApplicator, sheet, propertyID, handles, specificity);
266+
break;
267+
}
267268
}
268269
}
269270
}

Modules/UIElementsDebuggerEditor/DebuggerTreeView.cs

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public IEnumerable<ITreeViewItem> treeItems
3131
}
3232
}
3333

34-
private IList<ITreeViewItem> m_TreeRootItems;
34+
private IList<ITreeViewItem> m_TreeRootItems = new List<ITreeViewItem>();
3535

3636
private TreeView m_TreeView;
3737
private HighlightOverlayPainter m_TreeViewHoverOverlay;
@@ -148,10 +148,20 @@ public void RebuildTree(IPanelDebug panelDebug)
148148
m_Container.Clear();
149149

150150
int nextId = 1;
151-
m_TreeRootItems = GetTreeItemsFromVisualTree(panelDebug?.visualTree, ref nextId);
152151

153-
if (panelDebug?.visualTree != null)
154-
m_TreeRootItems.Insert(0, new TreeViewItem<VisualElement>(0, panelDebug.visualTree));
152+
m_TreeRootItems.Clear();
153+
154+
var visualTree = panelDebug?.visualTree;
155+
if (visualTree != null)
156+
{
157+
var rootItem = new TreeViewItem<VisualElement>(nextId++, visualTree);
158+
m_TreeRootItems.Add(rootItem);
159+
160+
var childItems = new List<ITreeViewItem>();
161+
AddTreeItemsForElement(childItems, visualTree, ref nextId);
162+
163+
rootItem.AddChildren(childItems);
164+
}
155165

156166
Func<VisualElement> makeItem = () =>
157167
{
@@ -278,36 +288,30 @@ public void SelectElement(VisualElement element, string query, SearchHighlight s
278288
}
279289
}
280290

281-
private IList<ITreeViewItem> GetTreeItemsFromVisualTree(VisualElement parent, ref int nextId)
291+
private void AddTreeItemsForElement(IList<ITreeViewItem> items, VisualElement ve, ref int nextId)
282292
{
283-
List<ITreeViewItem> items = null;
284-
285-
if (parent == null)
286-
return null;
293+
if (ve == null)
294+
return;
287295

288-
int count = parent.hierarchy.childCount;
296+
int count = ve.hierarchy.childCount;
289297
if (count == 0)
290-
return null;
298+
return;
291299

292300
for (int i = 0; i < count; i++)
293301
{
294-
if (items == null)
295-
items = new List<ITreeViewItem>();
296-
297-
var element = parent.hierarchy[i];
302+
var child = ve.hierarchy[i];
298303

299-
var item = new TreeViewItem<VisualElement>(nextId, element);
300-
items.Add(item);
304+
var treeItem = new TreeViewItem<VisualElement>(nextId, child);
305+
items.Add(treeItem);
301306
nextId++;
302307

303-
var childItems = GetTreeItemsFromVisualTree(element, ref nextId);
304-
if (childItems == null)
308+
var childItems = new List<ITreeViewItem>();
309+
AddTreeItemsForElement(childItems, child, ref nextId);
310+
if (childItems.Count == 0)
305311
continue;
306312

307-
item.AddChildren(childItems);
313+
treeItem.AddChildren(childItems);
308314
}
309-
310-
return items;
311315
}
312316
}
313317
}

0 commit comments

Comments
 (0)