Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit 918b81a

Browse files
committed
v1
1 parent 08ee40d commit 918b81a

File tree

7 files changed

+31
-53
lines changed

7 files changed

+31
-53
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@
3535
*.csproj
3636
*.sln
3737
*.suo
38+
/Assets/Plugins

Assets/Examples/Scene/Text.unity

-667 Bytes
Binary file not shown.

Assets/Plugins.meta

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/TextInlineSprite/Scripts/InlineText.cs

Lines changed: 13 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class InlineText : Text
2222
{
2323
private static StringBuilder _textBuilder = new StringBuilder();
2424
private static UIVertex[] m_TempVerts = new UIVertex[4];
25-
private static UIVertex[] m_TagVerts = new UIVertex[4];
25+
private static Vector3[] m_TagVerts = new Vector3[2];
2626

2727
private TextGenerator _SpaceGen;
2828
private InlineManager _InlineManager;
@@ -67,13 +67,6 @@ protected override void Start()
6767
EmojiTools.AddUnityMemory(this);
6868
}
6969

70-
#if UNITY_EDITOR
71-
protected override void OnValidate()
72-
{
73-
//do nothing
74-
}
75-
#endif
76-
7770
public override void SetVerticesDirty()
7871
{
7972
base.SetVerticesDirty();
@@ -82,7 +75,6 @@ public override void SetVerticesDirty()
8275
if (!Manager)
8376
{
8477
_outputText = m_Text;
85-
return;
8678
}
8779
else if(Manager.HasInit)
8880
{
@@ -92,8 +84,10 @@ public override void SetVerticesDirty()
9284
{
9385
StartCoroutine(WaitManagerInited());
9486
}
95-
96-
87+
}
88+
else
89+
{
90+
_outputText = m_Text;
9791
}
9892
}
9993

@@ -117,11 +111,7 @@ void DoUpdateEmoji()
117111

118112
_outputText = _textBuilder.ToString();
119113
_textBuilder.Length = 0;
120-
121-
Debug.LogError(_outputText);
122-
}
123-
124-
114+
}
125115
}
126116

127117
protected override void OnDestroy()
@@ -199,22 +189,13 @@ protected override void OnPopulateMesh(VertexHelper toFill)
199189
//first
200190
if (startfilldata >= 0 && i == startfilldata)
201191
{
202-
m_TagVerts[0] = m_TempVerts[tempVertsIndex];
203-
}
204-
//second
205-
if (nextfilldata >= 0 && i == nextfilldata - 2)
206-
{
207-
m_TagVerts[1] = m_TempVerts[tempVertsIndex];
192+
m_TagVerts[0]= m_TempVerts[tempVertsIndex].position;
208193
}
194+
209195
//third
210196
if (nextfilldata >= 0 && i == nextfilldata - 1)
211197
{
212-
m_TagVerts[2] = m_TempVerts[tempVertsIndex];
213-
}
214-
//fourth
215-
if (startfilldata >= 0 && i == startfilldata + 3)
216-
{
217-
m_TagVerts[3] = m_TempVerts[tempVertsIndex];
198+
m_TagVerts[1] = m_TempVerts[tempVertsIndex].position;
218199
}
219200

220201
if (tempVertsIndex == 3)
@@ -243,22 +224,13 @@ protected override void OnPopulateMesh(VertexHelper toFill)
243224
//first
244225
if (startfilldata >= 0 && i == startfilldata)
245226
{
246-
m_TagVerts[0] = m_TempVerts[tempVertsIndex];
247-
}
248-
//second
249-
if (nextfilldata >= 0 && i == nextfilldata - 2)
250-
{
251-
m_TagVerts[1] = m_TempVerts[tempVertsIndex];
227+
m_TagVerts[0] = m_TempVerts[tempVertsIndex].position;
252228
}
229+
253230
//third
254231
if (nextfilldata >= 0 && i == nextfilldata - 1)
255232
{
256-
m_TagVerts[2] = m_TempVerts[tempVertsIndex];
257-
}
258-
//fourth
259-
if (startfilldata >= 0 && i == startfilldata + 3)
260-
{
261-
m_TagVerts[3] = m_TempVerts[tempVertsIndex];
233+
m_TagVerts[1] = m_TempVerts[tempVertsIndex].position;
262234
}
263235

264236
if (tempVertsIndex == 3)
@@ -287,7 +259,7 @@ void FillNextTag(ref int startfilldata,ref int nextfilldata,ref int fillindex)
287259
{
288260
//fill current
289261
var current = _renderTagList[fillindex];
290-
current.Fill(m_TagVerts);
262+
current.Fill(m_TagVerts[0],m_TagVerts[1]);
291263

292264
fillindex++;
293265
if (fillindex < _renderTagList.Count)

Assets/TextInlineSprite/Scripts/ParseData.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public interface IFillData
1515
Vector3[] pos { get; set; }
1616
Vector2[] uv { get; set; }
1717

18-
int Fill(UIVertex[] filler);
18+
int Fill(Vector3 start, Vector3 end);
1919

2020
int GetFillCnt();
2121

@@ -62,18 +62,19 @@ public int GetFillCnt()
6262
return _position / DV2;
6363
}
6464

65-
public int Fill(UIVertex[] filler)
65+
public int Fill(Vector3 start,Vector3 end)
6666
{
6767
int index = GetPositionIdx();
6868
if (index >= 0)
6969
{
70-
pos[0] = filler[0].position;
71-
pos[1] = filler[1].position;
72-
pos[2] = filler[2].position;
73-
pos[3] = filler[3].position;
74-
70+
float w = Mathf.Abs(end.x - start.x);
71+
float h = Mathf .Abs( end.y - start.y);
72+
Vector3 center = (start + end) / 2;
73+
pos[3] = center + new Vector3(-Size.x / 2,-Size.y / 2, 0);
74+
pos[2] = center + new Vector3(Size.x / 2, -Size.y / 2, 0);
75+
pos[1] = center + new Vector3(Size.x / 2, Size.y / 2, 0);
76+
pos[0] = center + new Vector3(-Size.x / 2, Size.y / 2, 0);
7577
}
76-
7778
return -1;
7879
}
7980

Assets/TextInlineSprite/Scripts/Parser/EmojiParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ void FillSpriteTag(InlineText text,StringBuilder stringBuilder, Match match,int
6464
float spaceheight = spaceverts[0].position.y - spaceverts[3].position.y;
6565

6666
float autosize = Mathf.Min(tagSprites.size, Mathf.Max(spacewid, spaceheight));
67-
float spacesize = Mathf.Max(spacewid, spaceheight);
67+
float spacesize = Mathf.Min(spacewid, spaceheight);
6868

69-
int fillspacecnt = Mathf.CeilToInt(autosize / spacesize);
69+
int fillspacecnt = Mathf.RoundToInt(autosize / spacesize);
7070

7171
for (int i = 0; i < fillspacecnt; i++)
7272
{

Assets/TextInlineSprite/Scripts/Parser/ParserTransmit.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ public void DoParse(InlineText text, StringBuilder fillbuilder, string content)
106106
parser.Hot = 0;
107107
}
108108
}
109+
else
110+
{
111+
fillbuilder.Append(content);
112+
}
109113
}
110114
else
111115
{

0 commit comments

Comments
 (0)