Skip to content

Commit c9606e8

Browse files
Merge pull request #8163 from Unity-Technologies/internal/master
Internal/master
2 parents 6afda01 + 9e50da6 commit c9606e8

File tree

261 files changed

+25370
-1868
lines changed

Some content is hidden

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

261 files changed

+25370
-1868
lines changed

Packages/com.unity.render-pipelines.core/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This version is compatible with Unity 6000.2.0b2.
2222

2323
## [17.0.3] - 2025-02-13
2424

25-
This version is compatible with Unity 6000.2.0a17.
25+
This version is compatible with Unity 6000.2.0a5.
2626

2727
### Added
2828
- Added Variable Rate Shading API support for (Raster)CommandBuffer(s), RenderGraph and RTHandles.

Packages/com.unity.render-pipelines.core/Documentation~/advanced-properties.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ There is a global state per user that stores if Unity displays **advanced proper
1414
Not every component or Volume Override includes advanced properties.
1515
If one does, it has a contextual menu to the right of each property section header that includes additional properties. To expose advanced properties for that section, open the contextual menu and click **Advanced Properties**.
1616

17-
For an example, see the **Water Surface** component in [High Definition Render Pipeline (HDRP)](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest).
17+
For an example, refer to the **Water Surface** component in [High Definition Render Pipeline (HDRP)](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest?subfolder=/manual/settings-and-properties-related-to-the-water-system.html).
1818

1919
By default only standard properties are shown.
2020

Packages/com.unity.render-pipelines.core/Editor/Controls.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
1+
using System.Collections.Generic;
2+
using UnityEngine;
3+
using UnityEngine.UIElements;
4+
5+
namespace UnityEditor.Rendering
6+
{
7+
[UxmlElement]
8+
internal partial class ToggleDropdown : VisualElement
9+
{
10+
const string k_StylesheetPathFormat = "Packages/com.unity.render-pipelines.core/Editor/Controls/ToggleDropdown.uss";
11+
const string k_MainClass = "toggle-dropdown";
12+
const string k_ToggleButtonClass = k_MainClass + "__toggle-button";
13+
const string k_DropdownButtonClass = k_MainClass + "__dropdown-button";
14+
const string k_SeparatorClass = k_MainClass + "__separator";
15+
const string k_EnabledClass = k_MainClass + "--enabled";
16+
17+
private Button m_ToggleButton;
18+
private Button m_DropdownButton;
19+
private VisualElement m_DropdownArrow;
20+
private VisualElement m_Separator;
21+
private List<string> m_Options = new List<string>();
22+
private HashSet<int> m_SelectedIndices = new HashSet<int>();
23+
private int m_SelectedIndex = 0;
24+
private bool m_IsEnabled = false;
25+
private string m_Text = "Toggle Dropdown";
26+
27+
[UxmlAttribute]
28+
public string text
29+
{
30+
get => m_Text;
31+
set
32+
{
33+
if (m_Text == value)
34+
return;
35+
m_Text = value;
36+
m_ToggleButton.text = m_Text;
37+
}
38+
}
39+
40+
[UxmlAttribute]
41+
private string options { get; set; } = "";
42+
43+
[UxmlAttribute("selected-index")]
44+
private int selectedIndex
45+
{
46+
get => m_SelectedIndex;
47+
set
48+
{
49+
if (m_SelectedIndex == value || value < 0)
50+
return;
51+
m_SelectedIndex = value;
52+
}
53+
}
54+
55+
[UxmlAttribute("selected-indices")]
56+
public string selectedIndices
57+
{
58+
get
59+
{
60+
var indices = new List<string>();
61+
foreach (int index in m_SelectedIndices)
62+
{
63+
indices.Add(index.ToString());
64+
}
65+
return string.Join(",", indices.ToArray());
66+
}
67+
set
68+
{
69+
m_SelectedIndices.Clear();
70+
if (!string.IsNullOrEmpty(value))
71+
{
72+
var indices = value.Split(',');
73+
foreach (var indexStr in indices)
74+
{
75+
if (int.TryParse(indexStr.Trim(), out int index) && index >= 0)
76+
{
77+
m_SelectedIndices.Add(index);
78+
}
79+
}
80+
}
81+
}
82+
}
83+
84+
[UxmlAttribute]
85+
public bool value
86+
{
87+
get => m_IsEnabled;
88+
set
89+
{
90+
if (m_IsEnabled == value)
91+
return;
92+
m_IsEnabled = value;
93+
UpdateEnabledState();
94+
}
95+
}
96+
97+
/// <summary>Get the currently selected option text (first selected)</summary>
98+
public string selectedOption
99+
{
100+
get
101+
{
102+
foreach (int index in m_SelectedIndices)
103+
{
104+
if (index < m_Options.Count)
105+
return m_Options[index];
106+
}
107+
return "";
108+
}
109+
}
110+
111+
/// <summary>Get all selected options</summary>
112+
public string[] selectedOptions
113+
{
114+
get
115+
{
116+
var result = new List<string>();
117+
foreach (int index in m_SelectedIndices)
118+
{
119+
if (index < m_Options.Count)
120+
result.Add(m_Options[index]);
121+
}
122+
return result.ToArray();
123+
}
124+
}
125+
126+
/// <summary>Get all selected indices</summary>
127+
public int[] GetSelectedIndices()
128+
{
129+
var result = new int[m_SelectedIndices.Count];
130+
int i = 0;
131+
foreach (int index in m_SelectedIndices)
132+
{
133+
result[i++] = index;
134+
}
135+
return result;
136+
}
137+
138+
/// <summary>Event fired when selection changes</summary>
139+
public event System.Action<int[]> selectionChanged;
140+
141+
/// <summary>Event fired when toggle state changes</summary>
142+
public event System.Action<bool> toggleChanged;
143+
144+
/// <summary>Constructor</summary>
145+
public ToggleDropdown()
146+
{
147+
styleSheets.Add(AssetDatabase.LoadAssetAtPath<StyleSheet>(k_StylesheetPathFormat));
148+
AddToClassList(k_MainClass);
149+
150+
RegisterCallback<AttachToPanelEvent>(DelayedInit);
151+
152+
m_ToggleButton = new Button(OnToggleClicked);
153+
m_ToggleButton.AddToClassList(k_ToggleButtonClass);
154+
Add(m_ToggleButton);
155+
156+
m_DropdownButton = new Button(ShowCustomDropdown);
157+
m_DropdownButton.AddToClassList(k_DropdownButtonClass);
158+
159+
m_DropdownArrow = new VisualElement();
160+
m_DropdownArrow.AddToClassList("unity-toolbar-menu__arrow");
161+
m_DropdownButton.Add(m_DropdownArrow);
162+
163+
m_Separator = new VisualElement();
164+
m_Separator.AddToClassList(k_SeparatorClass);
165+
Add(m_Separator);
166+
167+
Add(m_DropdownButton);
168+
}
169+
170+
void DelayedInit(AttachToPanelEvent evt)
171+
{
172+
if (!string.IsNullOrEmpty(options))
173+
{
174+
var optionArray = options.Split(',');
175+
for (int i = 0; i < optionArray.Length; i++)
176+
{
177+
optionArray[i] = optionArray[i].Trim();
178+
}
179+
SetOptions(optionArray);
180+
}
181+
182+
if (selectedIndex >= 0)
183+
{
184+
m_SelectedIndices.Add(selectedIndex);
185+
}
186+
187+
m_IsEnabled = value;
188+
m_ToggleButton.text = m_Text;
189+
UpdateEnabledState();
190+
}
191+
192+
/// <summary>Set the available options for the dropdown</summary>
193+
public void SetOptions(string[] newOptions)
194+
{
195+
m_Options.Clear();
196+
if (newOptions != null)
197+
m_Options.AddRange(newOptions);
198+
199+
if (m_SelectedIndex >= m_Options.Count)
200+
m_SelectedIndex = 0;
201+
}
202+
203+
/// <summary>Set the selected indices for multi-select</summary>
204+
public void SetSelectedIndices(int[] indices)
205+
{
206+
m_SelectedIndices.Clear();
207+
if (indices != null)
208+
{
209+
foreach (int index in indices)
210+
{
211+
if (index >= 0 && index < m_Options.Count)
212+
{
213+
m_SelectedIndices.Add(index);
214+
}
215+
}
216+
}
217+
selectionChanged?.Invoke(GetSelectedIndices());
218+
}
219+
220+
/// <summary>Toggle selection of a specific index</summary>
221+
public void ToggleSelection(int index)
222+
{
223+
if (index >= 0 && index < m_Options.Count)
224+
{
225+
if (m_SelectedIndices.Contains(index))
226+
{
227+
m_SelectedIndices.Remove(index);
228+
}
229+
else
230+
{
231+
m_SelectedIndices.Add(index);
232+
}
233+
selectionChanged?.Invoke(GetSelectedIndices());
234+
}
235+
}
236+
237+
/// <summary>Check if an index is selected</summary>
238+
public bool IsSelected(int index)
239+
{
240+
return m_SelectedIndices.Contains(index);
241+
}
242+
243+
/// <summary>Set the enabled state</summary>
244+
public new void SetEnabled(bool enabled)
245+
{
246+
if (enabled != m_IsEnabled)
247+
{
248+
m_IsEnabled = enabled;
249+
UpdateEnabledState();
250+
toggleChanged?.Invoke(enabled);
251+
}
252+
}
253+
254+
void OnToggleClicked()
255+
{
256+
SetEnabled(!m_IsEnabled);
257+
}
258+
259+
void UpdateEnabledState()
260+
{
261+
if (m_IsEnabled)
262+
{
263+
AddToClassList(k_EnabledClass);
264+
}
265+
else
266+
{
267+
RemoveFromClassList(k_EnabledClass);
268+
}
269+
270+
MarkDirtyRepaint();
271+
}
272+
273+
void ShowCustomDropdown()
274+
{
275+
var menu = new GenericMenu();
276+
277+
for (int i = 0; i < m_Options.Count; i++)
278+
{
279+
int index = i;
280+
string optionName = m_Options[i];
281+
bool isSelected = m_SelectedIndices.Contains(index);
282+
283+
menu.AddItem(new GUIContent(optionName), isSelected, () => {
284+
ToggleSelection(index);
285+
});
286+
}
287+
288+
var rect = this.worldBound;
289+
menu.DropDown(rect);
290+
}
291+
}
292+
}

Packages/com.unity.render-pipelines.core/Editor/Controls/ToggleDropdown.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.

0 commit comments

Comments
 (0)