Skip to content

Commit f1d5ddb

Browse files
authored
Merge pull request #8031 from Unity-Technologies/internal/master
Internal/master
2 parents c9831bf + 1820b10 commit f1d5ddb

File tree

1,385 files changed

+877186
-343103
lines changed

Some content is hidden

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

1,385 files changed

+877186
-343103
lines changed

Packages/com.unity.render-pipelines.core/Editor/Analytics/AnalyticsUtils.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ static string[] ToStringArray(Dictionary<string, string> diff)
231231
/// <param name="current">The current object to obtain the fields and values.</param>
232232
/// <param name="compareAndSimplifyWithDefault">If a comparison against the default value must be done.</param>
233233
/// <returns>The nested columns in form of {key.nestedKey : value} </returns>
234-
/// <exception cref="ArgumentNullException"></exception>
235234
public static string[] ToNestedColumn<T>([DisallowNull] this T current, bool compareAndSimplifyWithDefault = false)
236235
where T : new()
237236
{
@@ -262,6 +261,28 @@ public static string[] ToNestedColumn<T>([DisallowNull] this T current, bool com
262261
return ToStringArray(diff);
263262
}
264263

264+
/// <summary>
265+
/// Obtains the Serialized fields and values in form of nested columns for BigQuery
266+
/// https://cloud.google.com/bigquery/docs/nested-repeated
267+
/// </summary>
268+
/// <typeparam name="T">The given type</typeparam>
269+
/// <param name="current">The current object to obtain the fields and values.</param>
270+
/// <param name="defaultInstance">The default instance to compare values</param>
271+
/// <returns>The nested columns in form of {key.nestedKey : value} </returns>
272+
public static string[] ToNestedColumn<T>([DisallowNull] this T current, T defaultInstance)
273+
{
274+
if (current == null)
275+
throw new ArgumentNullException(nameof(current));
276+
277+
if (defaultInstance == null)
278+
throw new ArgumentNullException(nameof(defaultInstance));
279+
280+
var type = current.GetType();
281+
282+
Dictionary<string, string> diff = GetDiffAsDictionary(type, current, defaultInstance);
283+
return ToStringArray(diff);
284+
}
285+
265286

266287
/// <summary>
267288
/// Obtains the Serialized fields and values in form of nested columns for BigQuery
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using System;
2+
using UnityEditor.Build;
3+
using UnityEditor.Build.Reporting;
4+
using UnityEngine.Analytics;
5+
using UnityEngine.Rendering;
6+
7+
namespace UnityEditor.Rendering
8+
{
9+
class RenderPipelineGraphicsSettingsAnalytics : IPostprocessBuildWithReport
10+
{
11+
const int k_MaxEventsPerHour = 1000;
12+
const int k_MaxNumberOfElements = 1000;
13+
const string k_VendorKey = "unity.srp";
14+
const string k_EventName = "uRenderPipelineGraphicsSettingsUsage";
15+
16+
[AnalyticInfo(eventName: k_EventName, vendorKey: k_VendorKey, maxEventsPerHour: k_MaxEventsPerHour, maxNumberOfElements: k_MaxNumberOfElements)]
17+
public class Analytic : IAnalytic
18+
{
19+
[Serializable]
20+
public struct AnalyticsData : IAnalytic.IData
21+
{
22+
public string settings;
23+
public string[] usage;
24+
}
25+
26+
public bool TryGatherData(out IAnalytic.IData data, out Exception error)
27+
{
28+
data = GatherDataToBeSent();
29+
error = null;
30+
return true;
31+
}
32+
33+
public static IAnalytic.DataList<AnalyticsData> GatherDataToBeSent()
34+
{
35+
using (ListPool<AnalyticsData>.Get(out var tmp))
36+
{
37+
GraphicsSettings.ForEach(settings =>
38+
{
39+
var settingsType = settings.GetType();
40+
var usage = settings.ToNestedColumn(Activator.CreateInstance(settingsType));
41+
if (usage.Length != 0)
42+
tmp.Add(new AnalyticsData() { settings = settingsType.FullName, usage = usage });
43+
});
44+
45+
return new IAnalytic.DataList<AnalyticsData>(tmp.ToArray());
46+
}
47+
}
48+
}
49+
50+
static void SendUniversalEvent()
51+
{
52+
//The event shouldn't be able to report if this is disabled but if we know we're not going to report
53+
//Lets early out and not waste time gathering all the data
54+
if (!EditorAnalytics.enabled)
55+
return;
56+
57+
Analytic analytic = new Analytic();
58+
EditorAnalytics.SendAnalytic(analytic);
59+
}
60+
61+
public int callbackOrder { get; }
62+
public void OnPostprocessBuild(BuildReport report)
63+
{
64+
SendUniversalEvent();
65+
}
66+
}
67+
}

Packages/com.unity.render-pipelines.core/Editor/Analytics/RenderPipelineGraphicsSettingsAnalytics.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Packages/com.unity.render-pipelines.core/Editor/BuildProcessors/CoreBuildData.cs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,30 @@ private CoreBuildData(BuildTarget buildTarget)
5252
var asset = renderPipelineAssets[0];
5353
currentRenderPipelineAssetType = asset.GetType();
5454

55-
CheckGPUResidentDrawerUsage(asset);
55+
CheckGPUResidentDrawerUsage();
5656
}
5757

5858
private static CoreBuildData CreateInstance()
5959
=> new(EditorUserBuildSettings.activeBuildTarget);
6060

61-
private void CheckGPUResidentDrawerUsage(RenderPipelineAsset asset)
61+
private void CheckGPUResidentDrawerUsage()
6262
{
63-
//We can check only the first as we don't support multiple pipeline type in player
64-
pipelineSupportGPUResidentDrawer = asset is IGPUResidentRenderPipeline gpuResidentRenderPipeline && gpuResidentRenderPipeline.IsGPUResidentDrawerSupportedBySRP();
65-
if (!pipelineSupportGPUResidentDrawer)
66-
return;
67-
68-
foreach (IGPUResidentRenderPipeline gpuResidentPipelineAsset in renderPipelineAssets)
69-
if (gpuResidentPipelineAsset.gpuResidentDrawerSettings.mode != GPUResidentDrawerMode.Disabled)
63+
foreach (var renderPipelineAsset in renderPipelineAssets)
64+
{
65+
if (renderPipelineAsset is IGPUResidentRenderPipeline gpuResidentPipelineAsset
66+
&& gpuResidentPipelineAsset.IsGPUResidentDrawerSupportedBySRP())
7067
{
71-
playerNeedGPUResidentDrawer = true;
72-
break;
68+
// Record if any pipeline supports the GPU resident drawer
69+
pipelineSupportGPUResidentDrawer = true;
70+
71+
// If any pipeline already has GPU resident drawer enabled, then record this and also early out
72+
if (gpuResidentPipelineAsset.gpuResidentDrawerSettings.mode != GPUResidentDrawerMode.Disabled)
73+
{
74+
playerNeedGPUResidentDrawer = true;
75+
break;
76+
}
7377
}
78+
}
7479

7580
if (!playerNeedGPUResidentDrawer)
7681
return;

Packages/com.unity.render-pipelines.core/Editor/HeaderFoldout.cs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@
55
namespace UnityEditor.Rendering
66
{
77
/// <summary> UITK component to display header styled foldout</summary>
8-
public class HeaderFoldout : Foldout
8+
[UxmlElement]
9+
public partial class HeaderFoldout : Foldout
910
{
1011
const string k_StylesheetPathFormat = "Packages/com.unity.render-pipelines.core/Editor/StyleSheets/HeaderFoldout{0}.uss";
1112
const string k_Class = "header-foldout";
13+
const string k_IconName = "header-foldout__icon";
1214

1315
private string m_DocumentationURL;
16+
private Texture2D m_Icon;
1417
private Func<GenericMenu> m_ContextMenuGenerator;
1518
private VisualElement m_HelpButton;
1619
private VisualElement m_ContextMenuButton;
20+
private VisualElement m_IconElement;
1721

1822
/// <summary>URL to use on documentation icon. If null, button don't show.</summary>
1923
public string documentationURL
@@ -29,7 +33,7 @@ public string documentationURL
2933
}
3034
}
3135

32-
/// <summary>Context menu to show on clic of the context button. If null, button don't show.</summary>
36+
/// <summary>Context menu to show on click of the context button. If null, button don't show.</summary>
3337
public Func<GenericMenu> contextMenuGenerator //Use ImGUI for now
3438
{
3539
get => m_ContextMenuGenerator;
@@ -42,6 +46,21 @@ public string documentationURL
4246
m_ContextMenuButton?.SetEnabled(m_ContextMenuGenerator != null);
4347
}
4448
}
49+
50+
/// <summary>Optional icon image. If not set, no icon is shown.</summary>
51+
public Texture2D icon
52+
{
53+
get => m_Icon;
54+
set
55+
{
56+
if (m_Icon == value)
57+
return;
58+
59+
m_Icon = value;
60+
m_IconElement.style.backgroundImage = Background.FromTexture2D(m_Icon);
61+
m_IconElement.style.display = m_Icon != null ? DisplayStyle.Flex : DisplayStyle.None;
62+
}
63+
}
4564

4665
/// <summary>Constructor</summary>
4766
public HeaderFoldout() : base()
@@ -61,6 +80,12 @@ public HeaderFoldout() : base()
6180
m_ContextMenuButton = new Button(Background.FromTexture2D(CoreEditorStyles.paneOptionsIcon), () => ShowMenu());
6281
m_ContextMenuButton.SetEnabled(m_ContextMenuGenerator != null);
6382
line.Add(m_ContextMenuButton);
83+
84+
m_IconElement = new Image();
85+
m_IconElement.name = k_IconName;
86+
m_IconElement.style.display = DisplayStyle.None; // Disable by default, will be enabled if icon is set
87+
// Delay insertion of icon to happen after foldout is constructed so we can put it in the right place
88+
RegisterCallbackOnce<AttachToPanelEvent>(evt => line.Insert(1, m_IconElement));
6489
}
6590

6691
void DelayedInit(AttachToPanelEvent evt)
616 Bytes
Loading

Packages/com.unity.render-pipelines.core/Editor/Icons/RenderGraphViewer/[email protected]

Lines changed: 167 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
273 Bytes
Loading

0 commit comments

Comments
 (0)