Files
JJBB/Assets/Project/Script/GUI/Role/AttrDescPanel.cs

43 lines
1.1 KiB
C#
Raw Permalink Normal View History

2024-08-23 15:49:34 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using GCGame.Table;
public class AttrDescPanel : MonoBehaviour {
public UIBackRayBehind behindMask;
public RectTransform descPanel;
public Text desc;
public Vector2 offset; // 和点击的属性偏离
private int lastAttrID; // 上一次显示的属性,再次点击会关闭该界面
private void Awake()
{
behindMask._BackClick.AddListener(Close);
lastAttrID = -1;
}
public void ShowAttr(int attrID, Transform selectAttrTran)
{
if(attrID == lastAttrID)
{
lastAttrID = -1;
}
else
{
lastAttrID = attrID;
desc.text = StrDictionary.GetClientDictionaryString("#{" + (attrID + 70000) + "}");
Vector3 pos = selectAttrTran.position;
descPanel.position = selectAttrTran.position + (Vector3)offset;
this.gameObject.SetActive(true);
}
}
public void Close()
{
this.gameObject.SetActive(false);
}
}