Skip to content

Commit b83b9d2

Browse files
author
Stewart Miles
committed
Fixed line splitting in text area windows.
Unity's labels can only display a limit number of characters so the text area window splits text into multiple label elements. The splitting was not taking into account line breaks so text would be split at very odd boundaries making things harder to read. This changes the line splitting to preferably occur on line breaks. Change-Id: I59d8fc897856da336df19a3324da313fb670b240
1 parent 9d7fac6 commit b83b9d2

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Android Resolver: Fixed resolution window progress bar exceeding 100%.
66
* Android Resolver: If AndroidX is detected in the set of resolved libraries,
77
the user will be prompted to enable the Jetifier.
8+
* Android Resolver: Improved text splitting in text area windows.
89
* iOS Resolver: Added support for Unity's breaking changes to the Xcode API
910
in 2019.3.+. Cocoapods are now added to build targets, Unity-iPhone and
1011
UnityFramework in Unity 2019.3+.

source/PlayServicesResolver/src/TextAreaDialog.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ protected virtual void OnGUI()
168168
const int chunkSize = 5000; // Conservative chunk size < 65k characters.
169169
while (bodyTextOffset < bodyText.Length)
170170
{
171-
int readSize = chunkSize;
172-
readSize = bodyTextOffset + readSize >= bodyText.Length ?
173-
bodyText.Length - bodyTextOffset : readSize;
174-
bodyTextList.Add(bodyText.Substring(bodyTextOffset, readSize));
171+
int searchSize = Math.Min(bodyText.Length - bodyTextOffset, chunkSize);
172+
int readSize = bodyText.LastIndexOf("\n", bodyTextOffset + searchSize, searchSize);
173+
readSize = readSize >= 0 ? readSize - bodyTextOffset + 1 : searchSize;
174+
bodyTextList.Add(bodyText.Substring(bodyTextOffset, readSize).TrimEnd());
175175
bodyTextOffset += readSize;
176176
}
177177
foreach (string bodyTextChunk in bodyTextList)

0 commit comments

Comments
 (0)