Skip to content

Commit

Permalink
Merge pull request #13 from Digital-Creativity-Labs/feature/improve-t…
Browse files Browse the repository at this point in the history
…ext-NO-type

Make multiline text fields wrap text by default and make default text…
  • Loading branch information
ddslawson committed Jan 19, 2024
2 parents bf85e93 + a442a05 commit 5313ecd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
7 changes: 7 additions & 0 deletions Assets/Editor/CuttingRoomEditor/Utils/UIElementsUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 9 additions & 5 deletions Assets/Resources/CuttingRoom/UI/Style/TextScreenTemplate.uss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion Assets/Resources/CuttingRoom/UI/TextScreenTemplate.uxml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<Style src="project://database/Assets/Resources/CuttingRoom/UI/Style/TextScreenTemplate.uss?fileID=7433441132597879392&amp;guid=ea7b9901a2a06404b9fb23512ae36472&amp;type=3#TextScreenTemplate" />
<ui:VisualElement name="RootElement" picking-mode="Ignore" class="fullscreen-canvas" style="align-items: center; justify-content: center;">
<ui:Label display-tooltip-when-elided="true" name="TextContainer" picking-mode="Ignore" text="test" class="text-container" />
<ui:Label display-tooltip-when-elided="true" name="TextContainer" picking-mode="Ignore" text="Text" enable-rich-text="false" class="text-container" style="overflow: visible; white-space: normal; align-items: center; justify-content: center; display: flex; visibility: visible;" />
</ui:VisualElement>
</ui:UXML>

0 comments on commit 5313ecd

Please sign in to comment.