Skip to content

Commit 851a7bd

Browse files
author
Unity Technologies
committed
Unity 6000.0.12f1 C# reference source code
1 parent 77b37cd commit 851a7bd

File tree

18 files changed

+206
-79
lines changed

18 files changed

+206
-79
lines changed

Editor/Mono/Audio/UIElements/AudioRandomRangeSliderTracker.cs

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Transactions;
77
using UnityEngine;
88
using UnityEngine.UIElements;
9+
using UnityEngine.UIElements.Layout;
910

1011
namespace UnityEditor.Audio.UIElements;
1112

@@ -57,6 +58,7 @@ internal static AudioRandomRangeSliderTracker Create(Slider parentSlider, Vector
5758
rangeTracker.RegisterCallback<CustomStyleResolvedEvent>(CustomStylesResolved);
5859
rangeTracker.m_ParentSlider.RegisterCallback<GeometryChangedEvent>(OnGeometryChanged);
5960
rangeTracker.RegisterCallback<PropertyChangedEvent>(OnPropertyChanged);
61+
rangeTracker.style.overflow = Overflow.Visible;
6062

6163
return rangeTracker;
6264
}
@@ -102,16 +104,27 @@ static void GenerateVisualContent(MeshGenerationContext context)
102104
var parentSlider = sliderTracker.m_ParentSlider;
103105
var contentRect = context.visualElement.contentRect;
104106

107+
var hasPositiveRandomizationApplied = range.y > 0.0f;
108+
var hasNegativeRandomizationApplied = range.x < 0.0f;
109+
105110
// Offset the range so it is centered around the parent slider's current value.
106111
range.x += parentSlider.value;
107112
range.y += parentSlider.value;
108113

109114
// Measured from a screenshot of the slider. The value is in pixels.
110115
var sliderHeadWidth = 10.0f;
116+
var trackHeight = contentRect.yMax - contentRect.yMin;
111117

112118
// Map the range from the slider value range (e.g. dB) to the horizontal span of the content-rect (px).
113-
var left = Map(range.y, parentSlider.lowValue, parentSlider.highValue, contentRect.xMin + sliderHeadWidth / 2.0f, contentRect.xMax - sliderHeadWidth / 2.0f);
114-
var right = Map(range.x, parentSlider.lowValue, parentSlider.highValue, contentRect.xMin + sliderHeadWidth / 2.0f, contentRect.xMax - sliderHeadWidth / 2.0f);
119+
var left = Map(range.x, parentSlider.lowValue, parentSlider.highValue, contentRect.xMin + sliderHeadWidth / 2.0f, contentRect.xMax - sliderHeadWidth / 2.0f);
120+
var right = Map(range.y, parentSlider.lowValue, parentSlider.highValue, contentRect.xMin + sliderHeadWidth / 2.0f, contentRect.xMax - sliderHeadWidth / 2.0f);
121+
122+
if (hasPositiveRandomizationApplied) { right += sliderHeadWidth / 2.0f; }
123+
if (hasNegativeRandomizationApplied) { left -= sliderHeadWidth / 2.0f; }
124+
125+
// Determine if the slider value is being clipped in either end.
126+
var lowEndClipped = left < contentRect.xMin;
127+
var highEndClipped = right > contentRect.xMax;
115128

116129
// Clamp the mapped range so that it lies within the boundaries of the content-rect.
117130
left = Mathf.Clamp(left, contentRect.xMin, contentRect.xMax);
@@ -126,5 +139,29 @@ static void GenerateVisualContent(MeshGenerationContext context)
126139
painter2D.LineTo(new Vector2(left, contentRect.yMax));
127140
painter2D.ClosePath();
128141
painter2D.Fill();
142+
143+
if (sliderTracker.enabledSelf && lowEndClipped)
144+
{
145+
painter2D.fillColor = sliderTracker.m_TrackerEnabledColor;
146+
painter2D.BeginPath();
147+
painter2D.MoveTo(new Vector2(contentRect.xMin - trackHeight * 2, contentRect.yMin));
148+
painter2D.LineTo(new Vector2(contentRect.xMin - trackHeight * 1, contentRect.yMin));
149+
painter2D.LineTo(new Vector2(contentRect.xMin - trackHeight * 1, contentRect.yMax));
150+
painter2D.LineTo(new Vector2(contentRect.xMin - trackHeight * 2, contentRect.yMax));
151+
painter2D.ClosePath();
152+
painter2D.Fill();
153+
}
154+
155+
if (sliderTracker.enabledSelf && highEndClipped)
156+
{
157+
painter2D.fillColor = sliderTracker.m_TrackerEnabledColor;
158+
painter2D.BeginPath();
159+
painter2D.MoveTo(new Vector2(contentRect.xMax + trackHeight * 1, contentRect.yMin));
160+
painter2D.LineTo(new Vector2(contentRect.xMax + trackHeight * 2, contentRect.yMin));
161+
painter2D.LineTo(new Vector2(contentRect.xMax + trackHeight * 2, contentRect.yMax));
162+
painter2D.LineTo(new Vector2(contentRect.xMax + trackHeight * 1, contentRect.yMax));
163+
painter2D.ClosePath();
164+
painter2D.Fill();
165+
}
129166
}
130167
}

Editor/Mono/BuildProfile/BuildProfileContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ internal static void HandlePendingChangesBeforeEnterPlaymode()
145145
/// activeProfileChanged += (BuildProfile prev, BuildProfile cur) => {}
146146
/// </code>
147147
/// </remarks>
148-
public event Action<BuildProfile, BuildProfile> activeProfileChanged;
148+
public static event Action<BuildProfile, BuildProfile> activeProfileChanged;
149149

150150
/// <summary>
151151
/// Stores metadata required for Build Profile window and legacy APIs

Editor/Mono/EditorWindow.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,8 +1384,6 @@ internal static void BuildWindowMenuListing()
13841384
foreach (var win in editorWindows.Where(e => !!e).OrderBy(e => e.titleContent.text))
13851385
{
13861386
var title = win.titleContent.text;
1387-
if (!String.IsNullOrEmpty(win.titleContent.tooltip) && win.titleContent.tooltip != title)
1388-
title = win.titleContent.tooltip;
13891387
title = title.Replace("/", "\\");
13901388
Menu.AddMenuItem($"{k_RootMenuItemName}/{menuIndex++} {title}", "", false, menuIdx++, () => win.Focus(), null);
13911389
}

Modules/AndroidJNI/AndroidApplication.bindings.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,20 @@ public static AndroidJavaObject unityPlayer
5757
private static AndroidConfiguration m_CurrentConfiguration;
5858

5959
[RequiredByNativeCode(GenerateProxy = true)]
60-
private static void ApplyConfiguration(AndroidConfiguration config, bool notifySubscribers)
60+
private static void SetCurrentConfiguration(AndroidConfiguration config)
6161
{
6262
m_CurrentConfiguration = config;
63+
}
6364

65+
[RequiredByNativeCode(GenerateProxy = true)]
66+
private static AndroidConfiguration GetCurrentConfiguration()
67+
{
68+
return m_CurrentConfiguration;
69+
}
70+
71+
[RequiredByNativeCode(GenerateProxy = true)]
72+
private static void DispatchConfigurationChanged(bool notifySubscribers)
73+
{
6474
if (notifySubscribers)
6575
onConfigurationChanged?.Invoke(m_CurrentConfiguration);
6676
}

Modules/AndroidJNI/Configuration/AndroidConfiguration.cs

Lines changed: 62 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,37 @@ public sealed class AndroidConfiguration
3838
const int ColorModeHdrMask = 12;
3939
const int ColorModeWideColorGamutMask = 3;
4040

41-
private int colorMode { get; }
42-
public int densityDpi { get; }
43-
public float fontScale { get; }
44-
public int fontWeightAdjustment { get; }
45-
public AndroidKeyboard keyboard { get; }
46-
public AndroidHardwareKeyboardHidden hardKeyboardHidden { get; }
47-
public AndroidKeyboardHidden keyboardHidden { get; }
48-
public int mobileCountryCode { get; }
49-
public int mobileNetworkCode { get; }
50-
public AndroidNavigation navigation { get; }
51-
public AndroidNavigationHidden navigationHidden { get; }
52-
public AndroidOrientation orientation { get; }
53-
public int screenHeightDp { get; }
54-
public int screenWidthDp { get; }
55-
public int smallestScreenWidthDp { get; }
56-
private int screenLayout { get; }
57-
public AndroidTouchScreen touchScreen { get; }
58-
private int uiMode { get; }
59-
private string primaryLocaleCountry { get; }
60-
private string primaryLocaleLanguage { get; }
41+
private int colorMode { get; set; }
42+
public int densityDpi { get; private set; }
43+
public float fontScale { get; private set; }
44+
public int fontWeightAdjustment { get; private set; }
45+
public AndroidKeyboard keyboard { get; private set; }
46+
public AndroidHardwareKeyboardHidden hardKeyboardHidden { get; private set; }
47+
public AndroidKeyboardHidden keyboardHidden { get; private set; }
48+
public int mobileCountryCode { get; private set; }
49+
public int mobileNetworkCode { get; private set; }
50+
public AndroidNavigation navigation { get; private set; }
51+
public AndroidNavigationHidden navigationHidden { get; private set; }
52+
public AndroidOrientation orientation { get; private set; }
53+
public int screenHeightDp { get; private set; }
54+
public int screenWidthDp { get; private set; }
55+
public int smallestScreenWidthDp { get; private set; }
56+
private int screenLayout { get; set; }
57+
public AndroidTouchScreen touchScreen { get; private set; }
58+
private int uiMode { get; set; }
59+
private string primaryLocaleCountry { get; set; }
60+
private string primaryLocaleLanguage { get; set; }
6161
// Having this as an array, because it seems you can have multiple locales set, but for now we can only acquire primary locale
6262
// In case we'll have a way to acquire multiple locales in the future, have this as an array to prevent API changes
63-
public AndroidLocale[] locales => new[] { new AndroidLocale(primaryLocaleCountry, primaryLocaleLanguage) };
63+
public AndroidLocale[] locales
64+
{
65+
get
66+
{
67+
if (primaryLocaleCountry == null && primaryLocaleLanguage == null)
68+
return new AndroidLocale[0];
69+
return new[] { new AndroidLocale(primaryLocaleCountry, primaryLocaleLanguage) };
70+
}
71+
}
6472

6573
// Below properties are not marshalled
6674
public AndroidColorModeHdr colorModeHdr => (AndroidColorModeHdr)(colorMode & ColorModeHdrMask);
@@ -72,6 +80,39 @@ public sealed class AndroidConfiguration
7280
public AndroidUIModeNight uiModeNight => (AndroidUIModeNight)(uiMode & UiModeNightMask);
7381
public AndroidUIModeType uiModeType => (AndroidUIModeType)(uiMode & UiModeTypeMask);
7482

83+
public AndroidConfiguration()
84+
{
85+
}
86+
87+
public AndroidConfiguration(AndroidConfiguration otherConfiguration)
88+
{
89+
this.CopyFrom(otherConfiguration);
90+
}
91+
92+
public void CopyFrom(AndroidConfiguration otherConfiguration)
93+
{
94+
colorMode = otherConfiguration.colorMode;
95+
densityDpi = otherConfiguration.densityDpi;
96+
fontScale = otherConfiguration.fontScale;
97+
fontWeightAdjustment = otherConfiguration.fontWeightAdjustment;
98+
keyboard = otherConfiguration.keyboard;
99+
hardKeyboardHidden = otherConfiguration.hardKeyboardHidden;
100+
keyboardHidden = otherConfiguration.keyboardHidden;
101+
mobileCountryCode = otherConfiguration.mobileCountryCode;
102+
mobileNetworkCode = otherConfiguration.mobileNetworkCode;
103+
navigation = otherConfiguration.navigation;
104+
navigationHidden = otherConfiguration.navigationHidden;
105+
orientation = otherConfiguration.orientation;
106+
screenHeightDp = otherConfiguration.screenHeightDp;
107+
screenWidthDp = otherConfiguration.screenWidthDp;
108+
smallestScreenWidthDp = otherConfiguration.smallestScreenWidthDp;
109+
screenLayout = otherConfiguration.screenLayout;
110+
touchScreen = otherConfiguration.touchScreen;
111+
uiMode = otherConfiguration.uiMode;
112+
primaryLocaleCountry = otherConfiguration.primaryLocaleCountry;
113+
primaryLocaleLanguage = otherConfiguration.primaryLocaleLanguage;
114+
}
115+
75116
[Preserve]
76117
public override string ToString()
77118
{

Modules/BuildProfileEditor/BuildProfileWindow.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,16 @@ public void CreateGUI()
147147
Application.OpenURL(k_DevOpsUrl);
148148
};
149149

150-
BuildProfileContext.instance.activeProfileChanged += OnActiveProfileChanged;
150+
BuildProfileContext.activeProfileChanged -= OnActiveProfileChanged;
151+
BuildProfileContext.activeProfileChanged += OnActiveProfileChanged;
151152
}
152153

153154
public void OnDisable()
154155
{
155156
DestroyImmediate(buildProfileEditor);
156-
BuildProfileContext.instance.activeProfileChanged -= OnActiveProfileChanged;
157+
158+
BuildProfileContext.activeProfileChanged -= OnActiveProfileChanged;
159+
157160
if (m_BuildProfileDataSource != null)
158161
{
159162
SendWorkflowReport();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Unity C# reference source
2+
// Copyright (c) Unity Technologies. For terms of use, see
3+
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4+
5+
using System;
6+
using System.Runtime.InteropServices;
7+
using UnityEngine.Bindings;
8+
9+
namespace UnityEngine.TextCore.Text
10+
{
11+
[VisibleToOtherModules("UnityEngine.UIElementsModule")]
12+
[StructLayout(LayoutKind.Sequential)]
13+
[NativeHeader("Modules/TextCoreTextEngine/Native/ATGMeshInfo.h")]
14+
internal struct ATGMeshInfo
15+
{
16+
public NativeTextElementInfo[] textElementInfos;
17+
public int fontAssetId;
18+
public int textElementCount;
19+
20+
[Ignore] // This field must be populated on the managed side
21+
public FontAsset fontAsset;
22+
}
23+
}

Modules/TextCoreTextEngine/Managed/NativeTextInfo.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ namespace UnityEngine.TextCore.Text
1414
[NativeHeader("Modules/TextCoreTextEngine/Native/TextInfo.h")]
1515
internal struct NativeTextInfo
1616
{
17-
public NativeTextElementInfo[] textElementInfos;
18-
public int[] fontAssetIds;
19-
public int[] fontAssetLastGlyphIndex;
20-
21-
[Ignore] // This field must be populated on the managed side
22-
public FontAsset[] fontAssets;
17+
public ATGMeshInfo[] meshInfos;
2318
}
2419
}

Modules/TextCoreTextEngine/Managed/TextGenerator/TextLib.bindings.cs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,16 @@ internal TextLib()
2828
internal NativeTextInfo GenerateText(NativeTextGenerationSettings settings)
2929
{
3030
var textInfo = GenerateTextInternal(settings);
31-
var textElementInfos = textInfo.textElementInfos;
32-
textInfo.fontAssets = new FontAsset[textInfo.fontAssetIds.Length];
3331

34-
int previousLastGlyphIndex = 0;
35-
for (int i = 0; i < textInfo.fontAssetIds.Length; i++)
32+
foreach (ref var meshInfo in textInfo.meshInfos.AsSpan())
3633
{
37-
var fa = FontAsset.GetFontAssetByID(textInfo.fontAssetIds[i]);
38-
textInfo.fontAssets[i] = fa;
34+
var fa = FontAsset.GetFontAssetByID(meshInfo.fontAssetId);
35+
meshInfo.fontAsset = fa;
3936

40-
for (int j = previousLastGlyphIndex; j < textInfo.fontAssetLastGlyphIndex[i]; j++)
37+
// TODO we should add glyphs in batch instead
38+
foreach (ref var textElementInfo in meshInfo.textElementInfos.AsSpan())
4139
{
42-
var glyphID = textElementInfos[j].glyphID;
40+
var glyphID = textElementInfo.glyphID;
4341

4442
bool success = fa.TryAddGlyphInternal((uint)glyphID, out var glyph);
4543
if (!success)
@@ -64,14 +62,12 @@ internal NativeTextInfo GenerateText(NativeTextGenerationSettings settings)
6462
bottomRightUV.x = topRightUV.x;
6563
bottomRightUV.y = bottomLeftUV.y;
6664

67-
textElementInfos[j].bottomLeft.uv0 = bottomLeftUV;
68-
textElementInfos[j].topLeft.uv0 = topLeftUV;
69-
textElementInfos[j].topRight.uv0 = topRightUV;
70-
textElementInfos[j].bottomRight.uv0 = bottomRightUV;
65+
textElementInfo.bottomLeft.uv0 = bottomLeftUV;
66+
textElementInfo.topLeft.uv0 = topLeftUV;
67+
textElementInfo.topRight.uv0 = topRightUV;
68+
textElementInfo.bottomRight.uv0 = bottomRightUV;
7169
}
72-
previousLastGlyphIndex = textInfo.fontAssetLastGlyphIndex[i];
7370
}
74-
7571
return textInfo;
7672
}
7773

Modules/UIBuilder/Editor/Builder/UxmlAttributesView/BuilderUxmlAttributesView.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,9 @@ protected virtual BuilderStyleRow CreateSerializedAttributeRow(UxmlSerializedAtt
11411141
var uxmlObjectField = CreateUxmlObjectAttributeRow(attribute, propertyPath);
11421142
uxmlObjectField.Bind(m_CurrentElementSerializedObject);
11431143
fieldElement.Add(uxmlObjectField);
1144+
1145+
// Disable template override support for UxmlObjects. (UUM-72789)
1146+
uxmlObjectField.SetEnabled(!isInTemplateInstance);
11441147
}
11451148
else
11461149
{

Modules/UIElements/Core/Controls/InputField/BaseField.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,23 +215,21 @@ public virtual TValueType value
215215
{
216216
if (!EqualsCurrentValue(value) || showMixedValue)
217217
{
218+
var previousValue = m_Value;
219+
SetValueWithoutNotify(value);
220+
221+
// We set showMixedValue after setting the value or it will revert the text back to the previous value. (UUUM-73855)
218222
showMixedValue = false;
223+
219224
if (panel != null)
220225
{
221-
var previousValue = m_Value;
222-
SetValueWithoutNotify(value);
223-
224226
using (ChangeEvent<TValueType> evt = ChangeEvent<TValueType>.GetPooled(previousValue, m_Value))
225227
{
226228
evt.elementTarget = this;
227229
SendEvent(evt, dispatchMode);
228230
}
229231
NotifyPropertyChanged(valueProperty);
230232
}
231-
else
232-
{
233-
SetValueWithoutNotify(value);
234-
}
235233
}
236234
}
237235
}

0 commit comments

Comments
 (0)