Skip to content

Commit 3a806e3

Browse files
Internal/master
Internal/master
2 parents 5b72378 + 76cdeec commit 3a806e3

File tree

649 files changed

+36774
-20818
lines changed

Some content is hidden

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

649 files changed

+36774
-20818
lines changed

Packages/com.unity.render-pipelines.core/Editor-PrivateShared/AssetCallbacks/AssetCreationUtil.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ static void CreateAsset(string name, Action<string> callback = null, string exte
9595
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, assetCreationCallback, name, icon, null, false);
9696
}
9797

98-
class AssetCreationCallback : ProjectWindowCallback.EndNameEditAction
98+
class AssetCreationCallback : ProjectWindowCallback.AssetCreationEndAction
9999
{
100100
public Action<string> callback;
101101
public string extension;
102102

103-
public override void Action(int instanceId, string pathName, string resourceFile)
103+
public override void Action(EntityId entityId, string pathName, string resourceFile)
104104
{
105105
string path = AssetDatabase.GenerateUniqueAssetPath(pathName + $".{extension}");
106106
callback?.Invoke(path);

Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/AssetsConverter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace UnityEditor.Rendering.Converter
66
{
7+
[Serializable]
78
internal abstract class AssetsConverter : IRenderPipelineConverter
89
{
910
protected abstract List<(string query, string description)> contextSearchQueriesAndIds { get; }

Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/RenderPipelineConverterManager.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Reflection;
4+
using NUnit.Framework;
45
using UnityEngine;
56

67
namespace UnityEditor.Rendering.Converter
@@ -79,7 +80,14 @@ public void OnBeforeSerialize()
7980

8081
public void OnAfterDeserialize()
8182
{
82-
83+
// Something null, remove it
84+
for (int i = converterStates.Count - 1; i >= 0; i--)
85+
{
86+
if (converterStates[i] == null || converterStates[i].converter == null)
87+
{
88+
converterStates.RemoveAt(i);
89+
}
90+
}
8391
}
8492
}
8593
}

Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/RenderPipelineConverterMaterialUpgrader.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
using System;
12
using System.Collections.Generic;
23
using System.Text;
34
using UnityEngine;
45

56
namespace UnityEditor.Rendering.Converter
67
{
8+
[Serializable]
79
internal abstract class RenderPipelineConverterMaterialUpgrader : AssetsConverter
810
{
911
public override bool isEnabled => m_UpgradersCache.Count > 0;

Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/Window/RenderPipelineConverterVisualElement.cs

Lines changed: 63 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ internal class RenderPipelineConverterVisualElement : VisualElement
2727
public bool isSelectedAndEnabled => converter.isEnabled && state.isSelected;
2828

2929
VisualElement m_RootVisualElement;
30+
ListView m_ItemsList;
31+
HeaderFoldout m_HeaderFoldout;
32+
VisualElement m_ListViewHeader;
33+
HelpBox m_NoItemsFound;
34+
HelpBox m_PressScan;
3035
Label m_PendingLabel;
3136
Label m_WarningLabel;
3237
Label m_ErrorLabel;
@@ -43,53 +48,26 @@ public RenderPipelineConverterVisualElement(Node<ConverterInfo> converterInfo)
4348
s_VisualTreeAsset.Value.CloneTree(m_RootVisualElement);
4449
m_RootVisualElement.styleSheets.Add(s_StyleSheet.Value);
4550

46-
m_RootVisualElement.SetEnabled(converter.isEnabled);
47-
m_RootVisualElement.Q<Label>("converterName").text = displayName;
48-
49-
var helpButton = m_RootVisualElement.Q<Button>("containerHelpButton");
50-
if (string.IsNullOrEmpty(converterInfo.helpUrl))
51-
{
52-
helpButton.style.display = DisplayStyle.None;
53-
}
54-
else
51+
m_HeaderFoldout = m_RootVisualElement.Q<HeaderFoldout>("conveterFoldout");
52+
m_HeaderFoldout.text = displayName;
53+
m_HeaderFoldout.tooltip = (converter.isEnabled) ? description : converter.isDisabledMessage;
54+
m_HeaderFoldout.SetEnabled(converter.isEnabled);
55+
m_HeaderFoldout.value = state.isExpanded;
56+
m_HeaderFoldout.RegisterCallback<ChangeEvent<bool>>((evt) =>
5557
{
56-
helpButton.Q<Image>("containerHelpImage").image = CoreEditorStyles.iconHelp;
57-
helpButton.RemoveFromClassList("unity-button");
58-
helpButton.AddToClassList(EditorGUIUtility.isProSkin ? "dark" : "light");
59-
helpButton.RegisterCallback<ClickEvent>((evt) =>
60-
{
61-
Help.BrowseURL(converterInfo.helpUrl);
62-
evt.StopPropagation(); // This toggle needs to stop propagation since it is inside another clickable element
63-
});
64-
}
58+
state.isExpanded = evt.newValue;
59+
});
60+
m_HeaderFoldout.showEnableCheckbox = true;
61+
m_HeaderFoldout.documentationURL = converterInfo.helpUrl;
6562

66-
var converterEnabledToggle = m_RootVisualElement.Q<Toggle>("converterEnabled");
67-
converterEnabledToggle.SetValueWithoutNotify(state.isSelected);
68-
converterEnabledToggle.RegisterCallback<ClickEvent>((evt) =>
63+
m_HeaderFoldout.enableToggle.SetValueWithoutNotify(state.isSelected);
64+
m_HeaderFoldout.enableToggle.RegisterCallback<ClickEvent>((evt) =>
6965
{
7066
state.isSelected = !state.isSelected;
7167
converterSelected?.Invoke();
7268
UpdateConversionInfo();
73-
evt.StopPropagation(); // This toggle needs to stop propagation since it is inside another clickable element
7469
});
7570

76-
var topElement = m_RootVisualElement.Q<VisualElement>("converterTopVisualElement");
77-
topElement.RegisterCallback<ClickEvent>((evt) =>
78-
{
79-
showMoreInfo?.Invoke();
80-
});
81-
topElement.tooltip = (converter.isEnabled) ? description : converter.isDisabledMessage;
82-
83-
topElement.RegisterCallback<TooltipEvent>(evt =>
84-
{
85-
// Show the tooltip around the toggle only
86-
var rect = converterEnabledToggle.worldBound;
87-
rect.position += new Vector2(150, -30); // offset it a bit to not be ove the toggle
88-
evt.rect = rect; // position area that triggers it
89-
evt.StopPropagation();
90-
});
91-
92-
9371
var allLabel = m_RootVisualElement.Q<Label>("all");
9472
allLabel.RegisterCallback<ClickEvent>((evt) =>
9573
{
@@ -103,22 +81,23 @@ public RenderPipelineConverterVisualElement(Node<ConverterInfo> converterInfo)
10381
Refresh();
10482
});
10583

106-
ListView listView = m_RootVisualElement.Q<ListView>("converterItems");
107-
listView.showBoundCollectionSize = false;
108-
listView.makeItem = () =>
84+
m_ListViewHeader = m_RootVisualElement.Q("listViewHeader");
85+
m_ItemsList = m_RootVisualElement.Q<ListView>("converterItems");
86+
m_ItemsList.showBoundCollectionSize = false;
87+
m_ItemsList.makeItem = () =>
10988
{
11089
var item = new RenderPipelineConverterItemVisualElement();
11190
item.itemSelectionChanged += UpdateInfo;
11291
return item;
11392
};
114-
listView.bindItem = (element, index) =>
93+
m_ItemsList.bindItem = (element, index) =>
11594
{
11695
var item = element as RenderPipelineConverterItemVisualElement;
11796
item.Bind(state.items[index]);
11897
};
119-
listView.selectionChanged += obj =>
98+
m_ItemsList.selectionChanged += obj =>
12099
{
121-
state.items[listView.selectedIndex].item.OnClicked();
100+
state.items[m_ItemsList.selectedIndex].item.OnClicked();
122101
};
123102

124103
// setup the images
@@ -137,6 +116,11 @@ public RenderPipelineConverterVisualElement(Node<ConverterInfo> converterInfo)
137116
m_ErrorLabel = m_RootVisualElement.Q<Label>("errorLabel");
138117
m_SuccessLabel = m_RootVisualElement.Q<Label>("successLabel");
139118

119+
m_NoItemsFound = m_RootVisualElement.Q<HelpBox>("noItemsFoundHelpBox");
120+
m_NoItemsFound.style.display = DisplayStyle.None;
121+
122+
m_PressScan = m_RootVisualElement.Q<HelpBox>("pressScanHelpBox");
123+
140124
Add(m_RootVisualElement);
141125
Refresh();
142126
}
@@ -156,7 +140,7 @@ public void UpdateInfo()
156140

157141
void UpdateSelectedConverterItemsLabel()
158142
{
159-
var text = $"{state.selectedItemsCount}/{state.items.Count} selected";
143+
var text = $" ({state.selectedItemsCount} of {state.items.Count})";
160144
m_RootVisualElement.Q<Label>("converterStats").text = text;
161145
}
162146

@@ -190,61 +174,43 @@ void SetSelected(Label label, bool selected)
190174

191175
void UpdateConversionInfo()
192176
{
193-
var info = GetConversionInfo();
194-
195-
m_RootVisualElement.Q<Label>("converterStateInfoL").text = info.message;
196-
m_RootVisualElement.Q<Label>("converterStateInfoL").style.unityFontStyleAndWeight = FontStyle.Bold;
197-
m_RootVisualElement.Q<Image>("converterStateInfoIcon").image = info.icon;
198-
199-
m_PendingLabel.text = $"{state.pending}";
200-
m_WarningLabel.text = $"{state.warnings}";
201-
m_ErrorLabel.text = $"{state.errors}";
202-
m_SuccessLabel.text = $"{state.success}";
203-
}
204-
205-
private (string message, Texture2D icon) GetConversionInfo()
206-
{
207-
if (!state.isSelected)
208-
return ("Converter Not Selected", null);
209-
210-
if (!state.isInitialized)
211-
return ("Initialization Pending", CoreEditorStyles.iconPending);
212-
213-
if (state.errors > 0)
214-
return ("Conversion Complete with Errors", CoreEditorStyles.iconFail);
215-
216-
if (state.warnings > 0)
217-
return ("Conversion Pending with Warnings", CoreEditorStyles.iconWarn);
218-
219-
if (state.pending > 0)
220-
return ("Conversion Pending", CoreEditorStyles.iconPending);
221-
222-
if (state.success > 0)
223-
return ("Conversion Complete", CoreEditorStyles.iconComplete);
224-
225-
return ("No items found to convert", CoreEditorStyles.iconInfo);
226-
}
227-
228-
public void ShowConverterLayout()
229-
{
230-
m_RootVisualElement.Q<VisualElement>("informationVE").style.display = DisplayStyle.Flex;
231-
m_RootVisualElement.Q<VisualElement>("converterItems").style.display = DisplayStyle.Flex;
232-
m_RootVisualElement.Q<ListView>("converterItems").itemsSource = state.items;
233-
}
177+
if (state.isInitialized)
178+
{
179+
m_PressScan.style.display = DisplayStyle.None;
180+
if (state.items.Count > 0)
181+
{
182+
m_NoItemsFound.style.display = DisplayStyle.None;
183+
m_ListViewHeader.style.display = DisplayStyle.Flex;
184+
m_ItemsList.style.display = DisplayStyle.Flex;
185+
m_ItemsList.itemsSource = state.items;
186+
187+
m_PendingLabel.text = $"{state.pending}";
188+
m_WarningLabel.text = $"{state.warnings}";
189+
m_ErrorLabel.text = $"{state.errors}";
190+
m_SuccessLabel.text = $"{state.success}";
191+
}
192+
else
193+
{
194+
m_NoItemsFound.style.display = DisplayStyle.Flex;
195+
m_ListViewHeader.style.display = DisplayStyle.None;
196+
m_ItemsList.style.display = DisplayStyle.None;
197+
}
198+
}
199+
else
200+
{
201+
m_PressScan.style.display = DisplayStyle.Flex;
234202

235-
public void HideConverterLayout()
236-
{
237-
m_RootVisualElement.Q<VisualElement>("converterItems").style.display = DisplayStyle.None;
238-
m_RootVisualElement.Q<VisualElement>("informationVE").style.display = DisplayStyle.None;
203+
m_NoItemsFound.style.display = DisplayStyle.None;
204+
m_ListViewHeader.style.display = DisplayStyle.None;
205+
m_ItemsList.style.display = DisplayStyle.None;
206+
}
239207
}
240208

241209
public void Refresh()
242210
{
243-
m_RootVisualElement.Q<ListView>("converterItems").Rebuild();
211+
m_ItemsList.Rebuild();
244212
UpdateInfo();
245-
m_RootVisualElement.SetEnabled(converter.isEnabled);
246-
m_RootVisualElement.Q<Label>("converterName").text = displayName;
247-
m_RootVisualElement.Q<VisualElement>("converterTopVisualElement").tooltip = (converter.isEnabled) ? description : converter.isDisabledMessage;
213+
m_HeaderFoldout.SetEnabled(converter.isEnabled);
248214
}
249215

250216
public void Scan(Action onScanFinish)
@@ -271,6 +237,8 @@ void OnConverterCompleteDataCollection(List<IRenderPipelineConverterItem> items)
271237

272238
state.isLoading = false;
273239
state.isInitialized = true;
240+
m_HeaderFoldout.value = true; // Expand the foldout when we perform a search
241+
m_ItemsList.itemsSource = state.items;
274242

275243
Refresh();
276244
onScanFinish?.Invoke();

Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/Window/RenderPipelineConverterVisualElement.uss

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,85 @@
99
.unity-list-view__empty-label {
1010
display: none;
1111
}
12+
13+
.render-pipeline-converter-items-header {
14+
display: flex;
15+
flex-direction: row;
16+
}
17+
18+
.render-pipeline-converter-all-none {
19+
display: flex;
20+
flex-direction: row;
21+
}
22+
23+
.render-pipeline-converter-helpbox
24+
{
25+
margin-bottom: 5px;
26+
flex-grow: 0;
27+
}
28+
29+
.render-pipeline-converter-information {
30+
flex-shrink: 1;
31+
flex-direction: column;
32+
margin-top: 10px;
33+
}
34+
35+
.render-pipeline-converter-label-all {
36+
width: 0;
37+
max-width: 26px;
38+
min-width: 26px;
39+
flex-grow: initial;
40+
}
41+
42+
.render-pipeline-converter-label-none {
43+
max-width: 36px;
44+
min-width: 36px;
45+
}
46+
47+
.render-pipeline-converter-items-header-flexrow {
48+
flex-grow: 1;
49+
flex-shrink: 0;
50+
background-color: rgba(0, 0, 0, 0);
51+
flex-direction: row;
52+
min-width: auto;
53+
min-height: auto;
54+
padding-right: 15px;
55+
padding-left: 4px;
56+
}
57+
.render-pipeline-converter-header-label {
58+
flex-grow: 1;
59+
}
60+
.render-pipeline-converter-header-label-upper-center {
61+
padding-left: 0;
62+
-unity-text-align: upper-center;
63+
padding-right: 0;
64+
}
65+
.render-pipeline-converter-header-label-nogrow {
66+
flex-grow: 0;
67+
flex-shrink: 0;
68+
padding-left: 0;
69+
-unity-text-align: upper-center;
70+
padding-right: 0;
71+
}
72+
.render-pipeline-converter-header-image {
73+
max-width: 16px;
74+
max-height: 16px;
75+
min-width: 16px;
76+
min-height: 16px;
77+
}
78+
.render-pipeline-converter-header-image-margin {
79+
padding-right: 0;
80+
margin-right: 8px;
81+
}
82+
.render-pipeline-converter-list-view {
83+
flex-grow: 2;
84+
flex-shrink: 1;
85+
height: auto;
86+
width: auto;
87+
padding-bottom: 0;
88+
margin-bottom: 0;
89+
margin-top: 0;
90+
max-height: initial;
91+
min-height: auto;
92+
padding-left: 10px;
93+
}

0 commit comments

Comments
 (0)