Skip to content

Commit 74434d4

Browse files
author
Bianca Marina Stana
committed
Merge branch 'unite2025/lsp-uitk' into unite2025/screen-reader-improvements
2 parents de93900 + 0267b85 commit 74434d4

File tree

7 files changed

+53
-15
lines changed

7 files changed

+53
-15
lines changed

Assets/Localization/String Tables/Game Text_en.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ MonoBehaviour:
168168
m_Items:
169169
- rid: 2216566543976235777
170170
- m_Id: 1468861612453888
171-
m_Localized: OS Settings (read-only)
171+
m_Localized: System Settings (read-only)
172172
m_Metadata:
173173
m_Items: []
174174
- m_Id: 1469259735789568

Assets/Localization/String Tables/Game Text_es.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ MonoBehaviour:
166166
m_Items:
167167
- rid: 2216566543976235779
168168
- m_Id: 1468861612453888
169-
m_Localized: "Configuraci\xF3n del SO (solo lectura)"
169+
m_Localized: "Configuraci\xF3n del sistema (solo lectura)"
170170
m_Metadata:
171171
m_Items: []
172172
- m_Id: 1469259735789568

Assets/Localization/String Tables/Game Text_ja.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ MonoBehaviour:
166166
m_Items:
167167
- rid: 2216566543976235778
168168
- m_Id: 1468861612453888
169-
m_Localized: "OS\u8A2D\u5B9A\uFF08\u8AAD\u307F\u53D6\u308A\u5C02\u7528\uFF09"
169+
m_Localized: "\u30B7\u30B9\u30C6\u30E0\u8A2D\u5B9A\uFF08\u8AAD\u307F\u53D6\u308A\u5C02\u7528\uFF09"
170170
m_Metadata:
171171
m_Items: []
172172
- m_Id: 1469259735789568

Assets/Resources/UITk/MainView.uxml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<UnityEngine.Localization.LocalizedString property="placeholderText" table="GUID:cc1d194facb1d9d4380a9ea2032c10ca" entry="Id(2876929896448)"/>
9797
</Bindings>
9898
</ui:TextField>
99-
<ui:Label class="settings-header-label">
99+
<ui:Label name="gameplayHeader" class="settings-header-label">
100100
<Bindings>
101101
<UnityEngine.Localization.LocalizedString property="text" table="GUID:cc1d194facb1d9d4380a9ea2032c10ca" entry="Id(3051354222592)"/>
102102
</Bindings>
@@ -146,7 +146,7 @@
146146
<UnityEngine.Localization.LocalizedString property="label" table="GUID:cc1d194facb1d9d4380a9ea2032c10ca" entry="Id(36785994493952)"/>
147147
</Bindings>
148148
</UnityEngine.Localization.LanguageSelection>
149-
<ui:Label class="settings-header-label">
149+
<ui:Label name="audioHeader" class="settings-header-label">
150150
<Bindings>
151151
<UnityEngine.Localization.LocalizedString property="text" table="GUID:cc1d194facb1d9d4380a9ea2032c10ca" entry="Id(17616599150592)"/>
152152
</Bindings>
@@ -163,7 +163,7 @@
163163
<UnityEngine.Localization.LocalizedString property="label" table="GUID:cc1d194facb1d9d4380a9ea2032c10ca" entry="Id(17842659553280)"/>
164164
</Bindings>
165165
</ui:Slider>
166-
<ui:Label text="Appearance" class="settings-header-label">
166+
<ui:Label name="appearanceHeader" text="Appearance" class="settings-header-label">
167167
<Bindings>
168168
<UnityEngine.Localization.LocalizedString property="text" table="GUID:cc1d194facb1d9d4380a9ea2032c10ca" entry="Id(18100730884096)"/>
169169
</Bindings>
@@ -181,7 +181,7 @@
181181
<UnityEngine.Localization.LocalizedString property="label" table="GUID:cc1d194facb1d9d4380a9ea2032c10ca" entry="Id(19534851502080)"/>
182182
</Bindings>
183183
</ui:Slider>
184-
<ui:Label class="settings-header-label">
184+
<ui:Label name="settingsHeader" class="settings-header-label">
185185
<Bindings>
186186
<UnityEngine.Localization.LocalizedString property="text" table="GUID:cc1d194facb1d9d4380a9ea2032c10ca" entry="Id(1468861612453888)"/>
187187
</Bindings>

Assets/Scripts/Screen Reader/UITk/Handlers/BaseFieldHandler.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using UnityEngine.Accessibility;
12
using UnityEngine.Scripting;
23
using UnityEngine.UIElements;
34

@@ -46,4 +47,20 @@ void EnsureLabelIsNotAccessible()
4647
}
4748
}
4849
}
50+
51+
[Preserve]
52+
class ToggleHandler : BaseFieldHandler<bool>
53+
{
54+
#if UNITY_2023_3_OR_NEWER
55+
public override AccessibilityRole GetRole() => AccessibilityRole.Toggle;
56+
#endif // UNITY_2023_3_OR_NEWER
57+
}
58+
59+
[Preserve]
60+
class RadioButtonHandler : BaseFieldHandler<bool>
61+
{
62+
#if UNITY_2023_3_OR_NEWER
63+
public override AccessibilityRole GetRole() => AccessibilityRole.Toggle;
64+
#endif // UNITY_2023_3_OR_NEWER
65+
}
4966
}

Assets/Scripts/Screen Reader/UITk/Handlers/VisualElementAccessibilityHandlerFactory.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ public static void RegisterBuiltinAccessibleElementFactories()
188188
RegisterGenericFactory(typeof(BaseSlider<>), typeof(BaseSliderHandler<>));
189189
RegisterGenericFactory(typeof(BasePopupField<,>), typeof(BasePopupFieldHandler<,>));
190190
RegisterFactory<TextField, TextFieldFieldHandler>();
191+
RegisterFactory<UnityEngine.UIElements.Toggle, ToggleHandler>();
192+
RegisterFactory<UnityEngine.UIElements.RadioButton, RadioButtonHandler>();
193+
191194
//RegisterFactory<DropdownField, DropdownFieldHandler>();
192195
RegisterFactory<ListView, ListViewHandler>();
193196
RegisterFactory<ScrollView, ScrollViewHandler>();

Assets/Scripts/UITk/MainView.cs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,19 @@ class MainView : MonoBehaviour
216216
Label m_ResultLabel;
217217
Button m_ScreenResultMainMenuButton;
218218
Button m_ScreenResultPlayAgainButton;
219+
219220
VisualElement m_SettingsView;
220221
Button m_CloseSettingsButton;
221222
Button m_SettingsButton;
222223
Button m_InGameSettingsButton;
223-
private TextField m_SearchField;
224+
TextField m_SearchField;
225+
Label m_GameplayHeader;
226+
Label m_AudioHeader;
227+
Label m_AppearanceHeader;
228+
Label m_SettingsHeader;
224229
VisualElement m_LastView;
225230
LetterCardListModel m_Model = new();
226-
231+
227232
// Label m_AnswerLabel;
228233

229234
Gameplay.DifficultyLevel m_SelectedDifficultyLevel = Gameplay.DifficultyLevel.Hard;
@@ -416,15 +421,28 @@ void SetupUI()
416421

417422
m_SettingsView = m_StackView.Q("settingsView");
418423
m_SettingsView.dataSource = m_PlayerSettings;
419-
424+
420425
var settingsScrollView = m_SettingsView.Q<ScrollView>("settingsScrollView");
421426
settingsScrollView.GetOrCreateAccessibleProperties().label = "Settings Scroll View";
422-
427+
423428
m_SearchField = m_SettingsView.Q<TextField>("settingsSearchField");
429+
// TODO: This should be localized.
424430
m_SearchField.GetOrCreateAccessibleProperties().label = "Search";
425431
m_SearchField.GetOrCreateAccessibleProperties().role = AccessibilityRole.SearchField;
426432
m_SearchField.RegisterValueChangedCallback((e) => UpdateSearchField());
427433

434+
m_GameplayHeader = m_SettingsView.Q<Label>("gameplayHeader");
435+
m_GameplayHeader.GetOrCreateAccessibleProperties().role = AccessibilityRole.Header;
436+
437+
m_AudioHeader = m_SettingsView.Q<Label>("audioHeader");
438+
m_AudioHeader.GetOrCreateAccessibleProperties().role = AccessibilityRole.Header;
439+
440+
m_AppearanceHeader = m_SettingsView.Q<Label>("appearanceHeader");
441+
m_AppearanceHeader.GetOrCreateAccessibleProperties().role = AccessibilityRole.Header;
442+
443+
m_SettingsHeader = m_SettingsView.Q<Label>("settingsHeader");
444+
m_SettingsHeader.GetOrCreateAccessibleProperties().role = AccessibilityRole.Header;
445+
428446
// m_SettingsPopup = new PopupWindow();
429447
// m_SettingsPopup.content = m_SettingsView;
430448

@@ -460,16 +478,16 @@ void SetupUI()
460478

461479
//root.Add(m_AnswerLabel = new Label());
462480
//m_AnswerLabel.style.position = Position.Absolute;
463-
481+
464482
}
465483

466484
void UpdateLangDirection(VisualElement root)
467485
{
468486
if (root.panel == null)
469487
return;
470-
488+
471489
bool isRightToLeft = LocalizationSettings.SelectedLocale?.Identifier.CultureInfo.TextInfo.IsRightToLeft ?? false;
472-
490+
473491
// Update text direction
474492
root.languageDirection = isRightToLeft ? LanguageDirection.RTL : LanguageDirection.LTR;
475493
root.panel.visualTree.EnableInClassList("lsp-dir-ltr", !isRightToLeft);
@@ -629,7 +647,7 @@ void UpdateSearchField()
629647
}
630648

631649
var label = field.Q<Label>();
632-
650+
633651
if (label != null && label.text.ToLowerInvariant().Contains(searchText))
634652
{
635653
field.parent.style.display = DisplayStyle.Flex;

0 commit comments

Comments
 (0)