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

Commit

Permalink
修复运行不显示表情的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
coding2233 committed Jul 15, 2017
1 parent 09cd9f2 commit de312ef
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Assets/TextInlineSprite/Editor/TextMenuExtender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static void CreateCustomGameObject(MenuCommand menuCommand)
else
{
go = new GameObject();
var line = go.AddComponent<InlineText>();
go.AddComponent<InlineText>();
}
go.name = "InlinText";
GameObject _parent = menuCommand.context as GameObject;
Expand Down
Binary file modified Assets/TextInlineSprite/Examples/Scene/Chat.unity
Binary file not shown.
Binary file modified Assets/TextInlineSprite/Examples/Scene/Text.unity
Binary file not shown.
4 changes: 2 additions & 2 deletions Assets/TextInlineSprite/Examples/Scripts/ChatTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public void OnClickSend()
return;

GameObject _chatClone = Instantiate(_PreChatItem);
_chatClone.transform.parent = _ChatParent;
_chatClone.transform.SetParent( _ChatParent);
InlineText _chatText = _chatClone.transform.FindChild("Text").GetComponent<InlineText>();
Image _chatImage= _chatClone.transform.FindChild("BG").GetComponent<Image>();
_chatText.text = _chatString;
_chatText.ActiveText();
// _chatText.ActiveText();
Vector2 _imagSize = _ChatTextSize;
if (_chatText.preferredWidth < _ChatTextSize.x)
_imagSize.x = _chatText.preferredWidth+0.3f;
Expand Down
7 changes: 3 additions & 4 deletions Assets/TextInlineSprite/Scripts/InlineManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class InlineManager : MonoBehaviour {
[SerializeField]
[Range(1,10)]
private float _AnimationSpeed = 5.0f;

// Use this for initialization
void Start()
{
Expand Down Expand Up @@ -86,7 +86,6 @@ public void UpdateTextInfo(int _id,InlineText _key, List<SpriteTagInfo> _value)
for (int i = 0; i < _value.Count; i++)
{
int m = i * 4;
int n = i * 6;
//标签
_meshInfo._Tag[i] = _value[i]._Tag;
//顶点位置
Expand All @@ -110,7 +109,7 @@ public void UpdateTextInfo(int _id,InlineText _key, List<SpriteTagInfo> _value)
}
else
_TextMeshInfo[_id].Add(_key, _meshInfo);

//更新图片
DrawSprites(_id);
}
Expand Down Expand Up @@ -140,7 +139,7 @@ private void DrawSpriteAnimation()
continue;
if (!_TextMeshInfo.ContainsKey(item.Key) || _TextMeshInfo[item.Key].Count <= 0)
continue;
SpriteGraphic _spriteGraphic = _IndexSpriteGraphic[item.Key]._SpriteGraphic;

//Mesh _mesh = _IndexSpriteGraphic[item.Key]._Mesh;
Dictionary<InlineText, MeshInfo> _data = _TextMeshInfo[item.Key];
foreach (var item02 in _data)
Expand Down
45 changes: 31 additions & 14 deletions Assets/TextInlineSprite/Scripts/InlineText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using UnityEngine.Events;
using System;

[ExecuteInEditMode]
public class InlineText : Text, IPointerClickHandler
{
// 用正则取 [图集ID#表情Tag] ID值==-1 ,表示为超链接
Expand All @@ -38,14 +37,38 @@ public class HrefClickEvent : UnityEvent<string> { }
// 超链接信息列表
private readonly List<HrefInfo> _ListHrefInfos = new List<HrefInfo>();
#endregion

/// <summary>
/// 初始化
/// </summary>
protected override void OnEnable()

///// <summary>
///// 初始化
///// </summary>
//protected override void OnEnable()
//{
// //
// base.OnEnable();
// //支持富文本
// supportRichText = true;
// //对齐几何
// alignByGeometry = true;
// if (!_InlineManager)
// _InlineManager = GetComponentInParent<InlineManager>();
// //启动的是 更新顶点
// SetVerticesDirty();
//}

protected override void Start()
{
ActiveText();
}

#if UNITY_EDITOR
protected override void OnValidate()
{
ActiveText();
}
#endif

public void ActiveText()
{
//
base.OnEnable();
//支持富文本
supportRichText = true;
//对齐几何
Expand All @@ -56,11 +79,6 @@ protected override void OnEnable()
SetVerticesDirty();
}

public void ActiveText()
{
OnEnable();
}

public override void SetVerticesDirty()
{
base.SetVerticesDirty();
Expand Down Expand Up @@ -184,7 +202,6 @@ void UpdateDrawnSprite()
foreach (var item in _SpriteInfo)
{
int _id = item.Value._ID;
string _tag = item.Value._Tag;

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

0 comments on commit de312ef

Please sign in to comment.