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

Commit de312ef

Browse files
committed
修复运行不显示表情的bug
1 parent 09cd9f2 commit de312ef

File tree

6 files changed

+37
-21
lines changed

6 files changed

+37
-21
lines changed

Assets/TextInlineSprite/Editor/TextMenuExtender.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static void CreateCustomGameObject(MenuCommand menuCommand)
1818
else
1919
{
2020
go = new GameObject();
21-
var line = go.AddComponent<InlineText>();
21+
go.AddComponent<InlineText>();
2222
}
2323
go.name = "InlinText";
2424
GameObject _parent = menuCommand.context as GameObject;
96 Bytes
Binary file not shown.
96 Bytes
Binary file not shown.

Assets/TextInlineSprite/Examples/Scripts/ChatTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ public void OnClickSend()
3333
return;
3434

3535
GameObject _chatClone = Instantiate(_PreChatItem);
36-
_chatClone.transform.parent = _ChatParent;
36+
_chatClone.transform.SetParent( _ChatParent);
3737
InlineText _chatText = _chatClone.transform.FindChild("Text").GetComponent<InlineText>();
3838
Image _chatImage= _chatClone.transform.FindChild("BG").GetComponent<Image>();
3939
_chatText.text = _chatString;
40-
_chatText.ActiveText();
40+
// _chatText.ActiveText();
4141
Vector2 _imagSize = _ChatTextSize;
4242
if (_chatText.preferredWidth < _ChatTextSize.x)
4343
_imagSize.x = _chatText.preferredWidth+0.3f;

Assets/TextInlineSprite/Scripts/InlineManager.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class InlineManager : MonoBehaviour {
2525
[SerializeField]
2626
[Range(1,10)]
2727
private float _AnimationSpeed = 5.0f;
28-
28+
2929
// Use this for initialization
3030
void Start()
3131
{
@@ -86,7 +86,6 @@ public void UpdateTextInfo(int _id,InlineText _key, List<SpriteTagInfo> _value)
8686
for (int i = 0; i < _value.Count; i++)
8787
{
8888
int m = i * 4;
89-
int n = i * 6;
9089
//标签
9190
_meshInfo._Tag[i] = _value[i]._Tag;
9291
//顶点位置
@@ -110,7 +109,7 @@ public void UpdateTextInfo(int _id,InlineText _key, List<SpriteTagInfo> _value)
110109
}
111110
else
112111
_TextMeshInfo[_id].Add(_key, _meshInfo);
113-
112+
114113
//更新图片
115114
DrawSprites(_id);
116115
}
@@ -140,7 +139,7 @@ private void DrawSpriteAnimation()
140139
continue;
141140
if (!_TextMeshInfo.ContainsKey(item.Key) || _TextMeshInfo[item.Key].Count <= 0)
142141
continue;
143-
SpriteGraphic _spriteGraphic = _IndexSpriteGraphic[item.Key]._SpriteGraphic;
142+
144143
//Mesh _mesh = _IndexSpriteGraphic[item.Key]._Mesh;
145144
Dictionary<InlineText, MeshInfo> _data = _TextMeshInfo[item.Key];
146145
foreach (var item02 in _data)

Assets/TextInlineSprite/Scripts/InlineText.cs

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
using UnityEngine.Events;
1717
using System;
1818

19-
[ExecuteInEditMode]
2019
public class InlineText : Text, IPointerClickHandler
2120
{
2221
// 用正则取 [图集ID#表情Tag] ID值==-1 ,表示为超链接
@@ -38,14 +37,38 @@ public class HrefClickEvent : UnityEvent<string> { }
3837
// 超链接信息列表
3938
private readonly List<HrefInfo> _ListHrefInfos = new List<HrefInfo>();
4039
#endregion
41-
42-
/// <summary>
43-
/// 初始化
44-
/// </summary>
45-
protected override void OnEnable()
40+
41+
///// <summary>
42+
///// 初始化
43+
///// </summary>
44+
//protected override void OnEnable()
45+
//{
46+
// //
47+
// base.OnEnable();
48+
// //支持富文本
49+
// supportRichText = true;
50+
// //对齐几何
51+
// alignByGeometry = true;
52+
// if (!_InlineManager)
53+
// _InlineManager = GetComponentInParent<InlineManager>();
54+
// //启动的是 更新顶点
55+
// SetVerticesDirty();
56+
//}
57+
58+
protected override void Start()
59+
{
60+
ActiveText();
61+
}
62+
63+
#if UNITY_EDITOR
64+
protected override void OnValidate()
65+
{
66+
ActiveText();
67+
}
68+
#endif
69+
70+
public void ActiveText()
4671
{
47-
//
48-
base.OnEnable();
4972
//支持富文本
5073
supportRichText = true;
5174
//对齐几何
@@ -56,11 +79,6 @@ protected override void OnEnable()
5679
SetVerticesDirty();
5780
}
5881

59-
public void ActiveText()
60-
{
61-
OnEnable();
62-
}
63-
6482
public override void SetVerticesDirty()
6583
{
6684
base.SetVerticesDirty();
@@ -184,7 +202,6 @@ void UpdateDrawnSprite()
184202
foreach (var item in _SpriteInfo)
185203
{
186204
int _id = item.Value._ID;
187-
string _tag = item.Value._Tag;
188205

189206
//更新绘制表情的信息
190207
List<SpriteTagInfo> _listSpriteInfo = null;

0 commit comments

Comments
 (0)