Browse Source

Correct TextAdapter RevealedChars in newer TMPro

FIx #862
In Unity 2020.1 TMpro is auto updated to 3.0.x and there is a slight behaviour change from TMPro 2.x that requires us to be more thorough is our use of maxVisibleCharacters.
Add TheExperiement_TMPro
master
Steve Halliwell 4 years ago
parent
commit
c0fe7869fe
  1. 7
      Assets/Fungus/Scripts/Utils/TextAdapter.cs
  2. 11717
      Assets/FungusExamples/TextMeshPro/TheExperiment_TMPro.unity
  3. 4
      Assets/FungusExamples/TextMeshPro/TheExperiment_TMPro.unity.meta
  4. 20
      Assets/Tests/WritingSpeedTest.unity
  5. 4
      ProjectSettings/ProjectVersion.txt

7
Assets/Fungus/Scripts/Utils/TextAdapter.cs

@ -238,9 +238,12 @@ namespace Fungus
get get
{ {
#if UNITY_2018_1_OR_NEWER #if UNITY_2018_1_OR_NEWER
if(tmpro != null) if (tmpro != null && tmpro.textInfo != null && tmpro.textInfo.characterInfo != null)
{
if (tmpro.maxVisibleCharacters < tmpro.textInfo.characterInfo.Length && tmpro.maxVisibleCharacters > 0)
{ {
return tmpro.textInfo.characterInfo[tmpro.maxVisibleCharacters].character; return tmpro.textInfo.characterInfo[tmpro.maxVisibleCharacters - 1].character;
}
} }
#endif #endif
return (char)0; return (char)0;

11717
Assets/FungusExamples/TextMeshPro/TheExperiment_TMPro.unity

File diff suppressed because it is too large Load Diff

4
Assets/FungusExamples/TextMeshPro/TheExperiment_TMPro.unity.meta

@ -0,0 +1,4 @@
fileFormatVersion: 2
guid: b217a13e3a0ce564cb2a2b400d8021db
DefaultImporter:
userData:

20
Assets/Tests/WritingSpeedTest.unity

@ -689,7 +689,7 @@ MonoBehaviour:
selectedBlocks: selectedBlocks:
- {fileID: 911349658} - {fileID: 911349658}
selectedCommands: selectedCommands:
- {fileID: 911349666} - {fileID: 911349661}
variables: [] variables: []
description: description:
stepPause: 0 stepPause: 0
@ -715,10 +715,9 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
itemId: 1 itemId: 1
indentLevel: 0 indentLevel: 0
storyText: '{s=10}asd .fas dfas, dfas {s=30}asd.fasd fa,sdfa .sdfa s{s=60}.asdf storyText: '{s=10}10 asd . dfas {s=30} 30 asd.fasd fa,sdfa s{s=60}60 asdf asdfa
asdfa .s, asd f{s=120}dfas dfasd fasd fa,sdf as dfas dfas dfasd fa{s=600}df a .s, asd f{s=120}120 dfas fa,sdf as dfas {s=600} 600 df dfas.dfa {s=0} 0 dfasdfasdfasd.f
sd f a s ,dfasdfas dfasdfasdfasd.f asd fasd,fa sd fa sd fasd fa sdfa sd fa .s asd fasd'
d fa sd fasdfasd fas dfasd,fa sdfas dfas.dfa'
description: description:
character: {fileID: 0} character: {fileID: 0}
portrait: {fileID: 0} portrait: {fileID: 0}
@ -808,10 +807,9 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
itemId: 4 itemId: 4
indentLevel: 0 indentLevel: 0
storyText: '{s=10}asd .fas dfas, dfas {s=30}asd.fasd fa,sdfa .sdfa s{s=60}.asdf storyText: '{s=10}10 asd . dfas {s=30} 30 asd.fasd fa,sdfa s{s=60}60 asdf asdfa
asdfa .s, asd f{s=120}dfas dfasd fasd fa,sdf as dfas dfas dfasd fa{s=600}df a .s, asd f{s=120}120 dfas fa,sdf as dfas {s=600} 600 df dfas.dfa {s=0} 0 dfasdfasdfasd.f
sd f a s ,dfasdfas dfasdfasdfasd.f asd fasd,fa sd fa sd fasd fa sdfa sd fa .s asd fasd'
d fa sd fasdfasd fas dfasd,fa sdfas dfas.dfa'
description: description:
character: {fileID: 0} character: {fileID: 0}
portrait: {fileID: 0} portrait: {fileID: 0}
@ -940,7 +938,7 @@ MonoBehaviour:
setSayDialog: {fileID: 0} setSayDialog: {fileID: 0}
--- !u!114 &911349667 --- !u!114 &911349667
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 2
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
@ -1694,6 +1692,7 @@ MonoBehaviour:
writeWholeWords: 0 writeWholeWords: 0
forceRichText: 1 forceRichText: 1
instantComplete: 1 instantComplete: 1
doReadAheadText: 1
--- !u!114 &1470136057 --- !u!114 &1470136057
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -2409,6 +2408,7 @@ MonoBehaviour:
writeWholeWords: 0 writeWholeWords: 0
forceRichText: 1 forceRichText: 1
instantComplete: 1 instantComplete: 1
doReadAheadText: 1
--- !u!114 &1802548009 --- !u!114 &1802548009
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

4
ProjectSettings/ProjectVersion.txt

@ -1,2 +1,2 @@
m_EditorVersion: 2019.4.8f1 m_EditorVersion: 2019.4.9f1
m_EditorVersionWithRevision: 2019.4.8f1 (60781d942082) m_EditorVersionWithRevision: 2019.4.9f1 (50fe8a171dd9)

Loading…
Cancel
Save