From a442a05757479a7cc96a7ae394e926cebe224108 Mon Sep 17 00:00:00 2001 From: Daniel Slawson Date: Fri, 19 Jan 2024 15:56:40 +0000 Subject: [PATCH] Make multiline text fields wrap text by default and make default text Narrative Object style wrap on screen too. --- .../CuttingRoomEditor/Utils/UIElementsUtils.cs | 7 +++++++ .../CuttingRoom/UI/Style/TextScreenTemplate.uss | 14 +++++++++----- .../CuttingRoom/UI/TextScreenTemplate.uxml | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Assets/Editor/CuttingRoomEditor/Utils/UIElementsUtils.cs b/Assets/Editor/CuttingRoomEditor/Utils/UIElementsUtils.cs index fc1e8bc..684b44d 100644 --- a/Assets/Editor/CuttingRoomEditor/Utils/UIElementsUtils.cs +++ b/Assets/Editor/CuttingRoomEditor/Utils/UIElementsUtils.cs @@ -286,6 +286,13 @@ public static VisualElement CreateTextFieldRow(string labelText, string value, b textField.isDelayed = true; textField.multiline = multiline; textField.value = value; + + if (multiline) + { + // Setting this means the text will wrap. + textField.style.whiteSpace = WhiteSpace.Normal; + } + textField.RegisterValueChangedCallback(evt => { OnValueChanged?.Invoke(evt.newValue); diff --git a/Assets/Resources/CuttingRoom/UI/Style/TextScreenTemplate.uss b/Assets/Resources/CuttingRoom/UI/Style/TextScreenTemplate.uss index d4c85c8..845f7b9 100644 --- a/Assets/Resources/CuttingRoom/UI/Style/TextScreenTemplate.uss +++ b/Assets/Resources/CuttingRoom/UI/Style/TextScreenTemplate.uss @@ -8,12 +8,16 @@ width: auto; justify-content: center; padding: 10%; - padding-left: 2px; - padding-right: 2px; - padding-top: 2px; - padding-bottom: 2px; + padding-left: 5px; + padding-right: 5px; + padding-top: 5px; + padding-bottom: 5px; font-size: 32px; - color: rgba(255, 255, 255, 255); + color: rgb(255, 255, 255); align-items: center; -unity-text-align: upper-center; + flex-wrap: wrap; + max-width: 90%; + max-height: 90%; + overflow: visible; } diff --git a/Assets/Resources/CuttingRoom/UI/TextScreenTemplate.uxml b/Assets/Resources/CuttingRoom/UI/TextScreenTemplate.uxml index 1f0edf8..ae091de 100644 --- a/Assets/Resources/CuttingRoom/UI/TextScreenTemplate.uxml +++ b/Assets/Resources/CuttingRoom/UI/TextScreenTemplate.uxml @@ -1,6 +1,6 @@