using DG.Tweening; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class WorkmanUIManager : MonoBehaviour { public GameObject m_LineGo; private Tween m_LineTween; private Transform m_LineGoTarget; public Vector3 offset; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if (m_LineGo.activeSelf && m_LineGoTarget != null) { Vector3 v = Camera.main.WorldToScreenPoint(m_LineGoTarget.position); if (v.z > 0) { v.z = 0; m_LineGo.transform.position = v + offset; } else { m_LineGo.transform.position = new Vector3(8888, 8888, 8888); } } } /// /// 展示标签 /// /// /// /// public void ShowLineGo(int type,string code, Transform target, bool isShow = true) { m_LineTween.Kill(); m_LineGo.transform.GetChild(0).GetComponent().fillAmount = 0; m_LineGo.transform.GetChild(0).GetChild(0).gameObject.SetActive(false); m_LineGo.SetActive(false); if (!isShow) return; m_LineGoTarget = target; m_LineTween = m_LineGo.transform.GetChild(0).GetComponent().DOFillAmount(1, 0.5f).OnComplete(() => { m_LineGo.transform.GetChild(0).GetChild(0).GetChild(0).GetComponent().text = type == 0 ? "名称" : "工艺"; m_LineGo.transform.GetChild(0).GetChild(0).GetChild(1).GetChild(0).GetChild(0).GetComponent().text = "\n" + code;//首行 m_LineGo.transform.GetChild(0).GetChild(0).gameObject.SetActive(true); }); m_LineGo.SetActive(isShow); } }