Skip to content

Commit 7a2bf11

Browse files
Junichi EnomotoJunichi Enomoto
authored andcommitted
fix : Small auto-sized text issue #5
1 parent e871262 commit 7a2bf11

11 files changed

Lines changed: 416 additions & 116 deletions

Assets/RubyTextMeshPro/Demo/Fonts/rounded-mplus-1c-regular SDF.asset

Lines changed: 102 additions & 91 deletions
Large diffs are not rendered by default.

Assets/RubyTextMeshPro/Source/RubyTextMeshPro.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,26 @@ protected enum RubyShowType
3434
[TextArea(5, 10)]
3535
private string m_uneditedText;
3636

37+
WaitForEndOfFrame waitForEndOfFrame = new WaitForEndOfFrame();
38+
3739
public string UnditedText
3840
{
39-
set { m_uneditedText = value; SetTextCustom(m_uneditedText); }
41+
set
42+
{
43+
m_uneditedText = value;
44+
SetTextCustom(m_uneditedText);
45+
if (enableAutoSizing)
46+
{
47+
StartCoroutine(WaitFrameUpdate(m_uneditedText));
48+
}
49+
}
4050
}
4151

52+
IEnumerator WaitFrameUpdate(string str)
53+
{
54+
yield return waitForEndOfFrame;
55+
SetTextCustom(m_uneditedText);
56+
}
4257
private void SetTextCustom(string value)
4358
{
4459
text = ReplaceRubyTags(value);
@@ -207,6 +222,11 @@ protected float ConvertToFloatOrigin(char[] chars, int startIndex, int lastIndex
207222
}
208223

209224
#if UNITY_EDITOR
225+
IEnumerator WaitFrameUpdateEditor(string str)
226+
{
227+
yield return null;
228+
SetTextCustom(m_uneditedText);
229+
}
210230

211231
protected override void OnValidate()
212232
{
@@ -215,6 +235,10 @@ protected override void OnValidate()
215235
ForceMeshUpdate();
216236

217237
SetTextCustom(m_uneditedText);
238+
if (enableAutoSizing)
239+
{
240+
StartCoroutine(WaitFrameUpdateEditor(m_uneditedText));
241+
}
218242
}
219243
#endif
220244
}

Assets/RubyTextMeshPro/Source/RubyTextMeshProUGUI.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,24 @@ protected enum RubyShowType
3434
[TextArea(5, 10)]
3535
private string m_uneditedText;
3636

37+
WaitForEndOfFrame waitForEndOfFrame = new WaitForEndOfFrame();
38+
3739
public string UnditedText
3840
{
39-
set { m_uneditedText = value; SetTextCustom(m_uneditedText); }
41+
set {
42+
m_uneditedText = value;
43+
SetTextCustom(m_uneditedText);
44+
if (enableAutoSizing)
45+
{
46+
StartCoroutine(WaitFrameUpdate(m_uneditedText));
47+
}
48+
}
49+
}
50+
51+
IEnumerator WaitFrameUpdate(string str)
52+
{
53+
yield return waitForEndOfFrame;
54+
SetTextCustom(m_uneditedText);
4055
}
4156

4257
private void SetTextCustom(string value)
@@ -146,6 +161,12 @@ private string CreateReplaceValue(string baseText, string rubyText, float rubyTe
146161
}
147162

148163
#if UNITY_EDITOR
164+
165+
IEnumerator WaitFrameUpdateEditor(string str)
166+
{
167+
yield return null;
168+
SetTextCustom(m_uneditedText);
169+
}
149170

150171
protected override void OnValidate()
151172
{
@@ -154,6 +175,10 @@ protected override void OnValidate()
154175
ForceMeshUpdate();
155176

156177
SetTextCustom(m_uneditedText);
178+
if (enableAutoSizing)
179+
{
180+
StartCoroutine(WaitFrameUpdateEditor(m_uneditedText));
181+
}
157182
}
158183
#endif
159184
}

Packages/manifest.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"dependencies": {
33
"com.unity.2d.sprite": "1.0.0",
4-
"com.unity.collab-proxy": "1.2.16",
5-
"com.unity.ext.nunit": "1.0.0",
6-
"com.unity.ide.rider": "1.1.4",
7-
"com.unity.textmeshpro": "2.1.1",
8-
"com.unity.ide.vscode": "1.2.2",
9-
"com.unity.test-framework": "1.1.18",
10-
"com.unity.timeline": "1.2.6",
4+
"com.unity.collab-proxy": "1.7.1",
5+
"com.unity.ext.nunit": "1.0.6",
6+
"com.unity.ide.rider": "2.0.7",
7+
"com.unity.ide.visualstudio": "2.0.11",
8+
"com.unity.ide.vscode": "1.2.3",
9+
"com.unity.test-framework": "1.1.27",
10+
"com.unity.textmeshpro": "3.0.6",
11+
"com.unity.timeline": "1.4.8",
1112
"com.unity.ugui": "1.0.0",
1213
"com.unity.modules.ai": "1.0.0",
1314
"com.unity.modules.androidjni": "1.0.0",

Packages/packages-lock.json

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,66 @@
77
"dependencies": {}
88
},
99
"com.unity.collab-proxy": {
10-
"version": "1.2.16",
10+
"version": "1.7.1",
1111
"depth": 0,
1212
"source": "registry",
13-
"dependencies": {},
13+
"dependencies": {
14+
"com.unity.nuget.newtonsoft-json": "2.0.0"
15+
},
1416
"url": "https://packages.unity.com"
1517
},
1618
"com.unity.ext.nunit": {
17-
"version": "1.0.0",
19+
"version": "1.0.6",
1820
"depth": 0,
1921
"source": "registry",
2022
"dependencies": {},
2123
"url": "https://packages.unity.com"
2224
},
2325
"com.unity.ide.rider": {
24-
"version": "1.1.4",
26+
"version": "2.0.7",
2527
"depth": 0,
2628
"source": "registry",
2729
"dependencies": {
2830
"com.unity.test-framework": "1.1.1"
2931
},
3032
"url": "https://packages.unity.com"
3133
},
34+
"com.unity.ide.visualstudio": {
35+
"version": "2.0.11",
36+
"depth": 0,
37+
"source": "registry",
38+
"dependencies": {
39+
"com.unity.test-framework": "1.1.9"
40+
},
41+
"url": "https://packages.unity.com"
42+
},
3243
"com.unity.ide.vscode": {
33-
"version": "1.2.2",
44+
"version": "1.2.3",
3445
"depth": 0,
3546
"source": "registry",
3647
"dependencies": {},
3748
"url": "https://packages.unity.com"
3849
},
50+
"com.unity.nuget.newtonsoft-json": {
51+
"version": "2.0.0",
52+
"depth": 1,
53+
"source": "registry",
54+
"dependencies": {},
55+
"url": "https://packages.unity.com"
56+
},
3957
"com.unity.test-framework": {
40-
"version": "1.1.18",
58+
"version": "1.1.27",
4159
"depth": 0,
4260
"source": "registry",
4361
"dependencies": {
44-
"com.unity.ext.nunit": "1.0.0",
62+
"com.unity.ext.nunit": "1.0.6",
4563
"com.unity.modules.imgui": "1.0.0",
4664
"com.unity.modules.jsonserialize": "1.0.0"
4765
},
4866
"url": "https://packages.unity.com"
4967
},
5068
"com.unity.textmeshpro": {
51-
"version": "2.1.1",
69+
"version": "3.0.6",
5270
"depth": 0,
5371
"source": "registry",
5472
"dependencies": {
@@ -57,10 +75,15 @@
5775
"url": "https://packages.unity.com"
5876
},
5977
"com.unity.timeline": {
60-
"version": "1.2.6",
78+
"version": "1.4.8",
6179
"depth": 0,
6280
"source": "registry",
63-
"dependencies": {},
81+
"dependencies": {
82+
"com.unity.modules.director": "1.0.0",
83+
"com.unity.modules.animation": "1.0.0",
84+
"com.unity.modules.audio": "1.0.0",
85+
"com.unity.modules.particlesystem": "1.0.0"
86+
},
6487
"url": "https://packages.unity.com"
6588
},
6689
"com.unity.ugui": {
@@ -205,6 +228,18 @@
205228
"depth": 0,
206229
"source": "builtin",
207230
"dependencies": {
231+
"com.unity.modules.ui": "1.0.0",
232+
"com.unity.modules.imgui": "1.0.0",
233+
"com.unity.modules.jsonserialize": "1.0.0",
234+
"com.unity.modules.uielementsnative": "1.0.0"
235+
}
236+
},
237+
"com.unity.modules.uielementsnative": {
238+
"version": "1.0.0",
239+
"depth": 1,
240+
"source": "builtin",
241+
"dependencies": {
242+
"com.unity.modules.ui": "1.0.0",
208243
"com.unity.modules.imgui": "1.0.0",
209244
"com.unity.modules.jsonserialize": "1.0.0"
210245
}

ProjectSettings/PackageManagerSettings.asset

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ MonoBehaviour:
99
m_GameObject: {fileID: 0}
1010
m_Enabled: 1
1111
m_EditorHideFlags: 0
12-
m_Script: {fileID: 0}
12+
m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0}
1313
m_Name:
14-
m_EditorClassIdentifier: UnityEditor:UnityEditor.PackageManager.UI:PackageManagerProjectSettings
14+
m_EditorClassIdentifier:
15+
m_EnablePreviewPackages: 0
16+
m_EnablePackageDependencies: 0
17+
m_AdvancedSettingsExpanded: 1
1518
m_ScopedRegistriesSettingsExpanded: 1
1619
oneTimeWarningShown: 0
1720
m_Registries:
@@ -20,6 +23,7 @@ MonoBehaviour:
2023
m_Url: https://packages.unity.com
2124
m_Scopes: []
2225
m_IsDefault: 1
26+
m_Capabilities: 7
2327
m_UserSelectedRegistryName:
2428
m_UserAddingNewScopedRegistry: 0
2529
m_RegistryInfoDraft:
@@ -30,6 +34,7 @@ MonoBehaviour:
3034
m_Url:
3135
m_Scopes: []
3236
m_IsDefault: 0
37+
m_Capabilities: 0
3338
m_Modified: 0
3439
m_Name:
3540
m_Url:

ProjectSettings/ProjectVersion.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
m_EditorVersion: 2019.4.13f1
2-
m_EditorVersionWithRevision: 2019.4.13f1 (518737b1de84)
1+
m_EditorVersion: 2020.3.17f1
2+
m_EditorVersionWithRevision: 2020.3.17f1 (a4537701e4ab)

0 commit comments

Comments
 (0)