81 lines
1.7 KiB
C#
81 lines
1.7 KiB
C#
|
/*-------------------------------------------------------------------------------------
|
||
|
--- 创建人:
|
||
|
--- 描 述:
|
||
|
--- 创建时间: 2023年1月14日
|
||
|
-------------------------------------------------------------------------------------*/
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
using Game;
|
||
|
using TMPro;
|
||
|
using Axibug.Runtime;
|
||
|
|
||
|
namespace Game
|
||
|
{
|
||
|
|
||
|
/// <summary>
|
||
|
/// xx 功能界面
|
||
|
/// </summary>
|
||
|
public class HPDamageShowUnit : MonoBehaviour
|
||
|
{
|
||
|
//UIAutoBuild_CtrlDefine
|
||
|
public TextMeshProUGUI tmpVal;
|
||
|
//UIAutoBuild_CtrlDefine
|
||
|
public Animator Anim;
|
||
|
public RectTransform rectTransform;
|
||
|
public Vector3 targetWorldPos;
|
||
|
|
||
|
public void Awake()
|
||
|
{
|
||
|
//UIAutoBuild_CtrlBind
|
||
|
Transform tf = transform;
|
||
|
tmpVal = tf.Find("tmpVal").GetComponent<TextMeshProUGUI>();
|
||
|
//UIAutoBuild_CtrlBind
|
||
|
Anim = tf.GetComponent<Animator>();
|
||
|
rectTransform = this.GetComponent<RectTransform>();
|
||
|
}
|
||
|
|
||
|
void OnEnable()
|
||
|
{
|
||
|
//UIAutoBuild_EventReg
|
||
|
//UIAutoBuild_EventReg
|
||
|
}
|
||
|
|
||
|
public void SetData(Transform transform,string HP)
|
||
|
{
|
||
|
SetData(transform.position, HP);
|
||
|
}
|
||
|
|
||
|
public void SetData(Vector3 worldPos, string HP)
|
||
|
{
|
||
|
// 转换为屏幕坐标
|
||
|
targetWorldPos = worldPos;
|
||
|
Vector3 Pos = Camera.main.WorldToScreenPoint(worldPos);
|
||
|
rectTransform.position = Pos;
|
||
|
|
||
|
tmpVal.text = HP;
|
||
|
Anim.Play("TextUp");
|
||
|
Invoke("EndEff", Anim.GetCurrentAnimatorStateInfo(0).length);
|
||
|
}
|
||
|
|
||
|
private void Update()
|
||
|
{
|
||
|
// 转换为屏幕坐标
|
||
|
rectTransform.position = Camera.main.WorldToScreenPoint(targetWorldPos);
|
||
|
}
|
||
|
|
||
|
public void EndEff()
|
||
|
{
|
||
|
this.gameObject.SetActive(false);
|
||
|
}
|
||
|
|
||
|
void OnDisable()
|
||
|
{
|
||
|
//UIAutoBuild_EventUnReg
|
||
|
//UIAutoBuild_EventUnReg
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|