Skip to content

Commit 77b0b5e

Browse files
committed
Fixed rich tag bug
1 parent 2c15d5b commit 77b0b5e

4 files changed

Lines changed: 19 additions & 13 deletions

File tree

Assets/Scenes/SampleScene.unity

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ MonoBehaviour:
177177
m_OnCullStateChanged:
178178
m_PersistentCalls:
179179
m_Calls: []
180-
m_text: "<shake:5>crazy</shake><wave:20> text effects \nwow isn't this so </wave><shake:5>cool"
180+
m_text: "<shake:10>fcrazy </shake> <wave:10>text <color=red>effects</color> \nwow
181+
isn't this so </wave> <wave:3><shake:5>cool"
181182
m_isRightToLeft: 0
182183
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
183184
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
@@ -204,7 +205,7 @@ MonoBehaviour:
204205
m_faceColor:
205206
serializedVersion: 2
206207
rgba: 4294967295
207-
m_fontSize: 60.9
208+
m_fontSize: 70.15
208209
m_fontSizeBase: 40.38
209210
m_fontWeight: 400
210211
m_enableAutoSizing: 1

Assets/TextParser.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88

99
public class TextParser : MonoBehaviour
1010
{
11-
//Regexes from https://github.com/markv12/VertexTextAnimationDemo
11+
//Remainder Regex from https://github.com/markv12/VertexTextAnimationDemo
1212

1313
private const string REMAINDER_REGEX = "(.*?((?=>)|(/|$)))";
1414

15+
//Because text mesh pro parses it's own tags, we need to find them
16+
private static readonly Regex richTagRegex = new Regex("<.*?>");
17+
1518
static readonly TextRegex[] textRegexes = {
1619
new("shake", new TextCharacterShakeEffect()),
1720
new("wave", new TextWaveEffect())
@@ -82,12 +85,14 @@ void UpdateRanges(int index, int length) {
8285
UpdateRanges(effectRanges[i].endIndex, effectRanges[i].endTagLength);
8386
}
8487

85-
// //Because the mesh doesn't have spaces
86-
// for(int i = 0; i < text.Length; i++) {
87-
// if(text[i] == ' ') {
88-
// UpdateRanges(i, 1);
89-
// }
90-
// }
88+
//Modifying the indexes to account for the removed non custom rich tags
89+
MatchCollection nonCustomTagMatches = richTagRegex.Matches(text);
90+
for(int i = 0; i < nonCustomTagMatches.Count; i++) {
91+
Match match = nonCustomTagMatches[i];
92+
if(match.Success) {
93+
UpdateRanges(match.Index, match.Length);
94+
}
95+
}
9196

9297
return effectRanges;
9398
}

Packages/packages-lock.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"url": "https://packages.unity.com"
1515
},
1616
"com.unity.2d.aseprite": {
17-
"version": "1.1.6",
17+
"version": "1.1.7",
1818
"depth": 1,
1919
"source": "registry",
2020
"dependencies": {
@@ -140,7 +140,7 @@
140140
"com.unity.2d.spriteshape": "10.0.7",
141141
"com.unity.2d.tilemap": "1.0.0",
142142
"com.unity.2d.tilemap.extras": "4.1.0",
143-
"com.unity.2d.aseprite": "1.1.6"
143+
"com.unity.2d.aseprite": "1.1.7"
144144
}
145145
},
146146
"com.unity.ide.rider": {

ProjectSettings/ProjectVersion.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
m_EditorVersion: 6000.0.26f1
2-
m_EditorVersionWithRevision: 6000.0.26f1 (ccb7c73d2c02)
1+
m_EditorVersion: 6000.0.32f1
2+
m_EditorVersionWithRevision: 6000.0.32f1 (b2e806cf271c)

0 commit comments

Comments
 (0)