61 lines
1.5 KiB
C#
61 lines
1.5 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.EventSystems;
|
|
using System;
|
|
using System.Collections;
|
|
|
|
|
|
public class ChatInfoLinkMask : MonoBehaviour, IPointerClickHandler
|
|
{
|
|
public Text _OutLine;
|
|
public Image Image;
|
|
public delegate void LinkClick(int linkIdx);
|
|
private LinkClick _LinkClick;
|
|
|
|
private int _LinkIdx;
|
|
|
|
public RectTransform rectTransform
|
|
{
|
|
get
|
|
{
|
|
return Image.rectTransform;
|
|
}
|
|
}
|
|
|
|
public void ShowOutLine(string lineColor,int fontSize,Color color)
|
|
{
|
|
if(_OutLine == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if(lineColor == "")
|
|
{
|
|
_OutLine.gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
|
|
_OutLine.gameObject.SetActive(true);
|
|
int length = Mathf.FloorToInt(rectTransform.sizeDelta.x / fontSize) * 2 + 1;
|
|
_OutLine.text = "_____________________________".Substring(0, length);
|
|
_OutLine.color = GCGame.Utils.GetColorByString(lineColor);
|
|
_OutLine.fontSize = fontSize;
|
|
_OutLine.rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, rectTransform.sizeDelta.y + 4);
|
|
_OutLine.rectTransform.anchoredPosition = Vector2.zero;
|
|
}
|
|
|
|
public void Init(LinkClick link, int idx)
|
|
{
|
|
_LinkClick = link;
|
|
_LinkIdx = idx;
|
|
}
|
|
|
|
public void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
if (_LinkClick != null)
|
|
{
|
|
_LinkClick(_LinkIdx);
|
|
}
|
|
}
|
|
}
|