119 lines
2.4 KiB
C#
119 lines
2.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System.Linq;
|
|
using DG.Tweening;
|
|
|
|
public class TipPlayerEx : MonoBehaviour
|
|
{
|
|
public static TipPlayerEx Instance;
|
|
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
public Text txtTitle;
|
|
|
|
public Button btnTitle;
|
|
|
|
public float autoHideTime = 3f;
|
|
|
|
Animator anim;
|
|
|
|
Data currentInfo;
|
|
|
|
void Start()
|
|
{
|
|
anim = GetComponent<Animator>();
|
|
}
|
|
|
|
public void OnBtnTitleClick()
|
|
{
|
|
//BaseController.CanControl = true;
|
|
|
|
GameObject obj = GameObject.Find(currentInfo.ParentID);
|
|
if (obj != null)
|
|
{
|
|
BaseShow[] bss = obj.GetComponents<BaseShow>();
|
|
foreach (var bs in bss)
|
|
{
|
|
bs.OnClick();
|
|
}
|
|
|
|
HideTip();
|
|
}
|
|
}
|
|
|
|
bool isShow;
|
|
|
|
public void ShowTip(Data info)
|
|
{
|
|
if (info != null && !string.IsNullOrEmpty(info.Title))
|
|
{
|
|
// ÏÔʾ
|
|
if (anim != null && !isShow)
|
|
{
|
|
// anim.SetTrigger("ShowTip");
|
|
anim.SetBool("IsShow", true);
|
|
}
|
|
|
|
//if (!isShow)
|
|
//{
|
|
// Tween myTween = transform.DOLocalMoveY(-490f, 0.5f);
|
|
// myTween.SetEase(Ease.OutQuint);
|
|
//}
|
|
|
|
isShow = true;
|
|
currentInfo = info;
|
|
txtTitle.text = info.Title;
|
|
|
|
this.GetComponent<RectTransform>().sizeDelta = new Vector2(
|
|
info.Title.Length * 30 + 50, 80);
|
|
current = 0f;
|
|
}
|
|
}
|
|
|
|
public void CheckTitle()
|
|
{
|
|
if(string.IsNullOrEmpty(txtTitle.text))
|
|
{
|
|
isShow = true;
|
|
HideTip();
|
|
}
|
|
}
|
|
public void HideTip()
|
|
{
|
|
// ¹Ø±Õ
|
|
if (anim != null && isShow)
|
|
{
|
|
anim.SetBool("IsShow", false);
|
|
//anim.SetTrigger("HideTip");
|
|
}
|
|
|
|
//if (isShow)
|
|
//{
|
|
// Tween myTween = transform.DOLocalMoveY(-590f, 0.2f);
|
|
// myTween.SetEase(Ease.OutQuint);
|
|
//}
|
|
|
|
isShow = false;
|
|
txtTitle.text = "";
|
|
current = 0f;
|
|
}
|
|
|
|
float current;
|
|
void Update()
|
|
{
|
|
if (isShow)
|
|
{
|
|
current += Time.deltaTime;
|
|
if (current >= 3f)
|
|
{
|
|
HideTip();
|
|
}
|
|
}
|
|
}
|
|
}
|