92 lines
2.4 KiB
C#
92 lines
2.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.EventSystems;
|
|
using TMPro;
|
|
|
|
public class Drainage_tip : MonoBehaviour, IPointerClickHandler
|
|
{
|
|
//相机跳转位置点
|
|
//public Transform cameraTarget;
|
|
private GameObject _mainCamera;
|
|
/// <summary>
|
|
/// 跟随 UI提示出现的位置
|
|
/// </summary>
|
|
public Transform m_FollowObj;
|
|
/// <summary>
|
|
/// 偏移
|
|
/// </summary>
|
|
public Vector3 m_Offset;
|
|
/// <summary>
|
|
/// 相机移动点
|
|
/// </summary>
|
|
//public Transform cameraTarget;
|
|
|
|
public TextMeshProUGUI biaoti_text;
|
|
public TextMeshProUGUI deep1_text;
|
|
public TextMeshProUGUI deep2_text;
|
|
//private TextMeshProUGUI biaoti_jilutext;
|
|
//弹出图片
|
|
public GameObject tanchuang;
|
|
private bool textUpdated = false;
|
|
|
|
void Start()
|
|
{
|
|
_mainCamera = GameObject.FindWithTag("MainCamera");
|
|
|
|
}
|
|
|
|
public void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
// 获取点击图片的名称
|
|
string imageName = gameObject.name;
|
|
tanchuang.SetActive(true);
|
|
biaoti_text.text = imageName + "号排水点";
|
|
|
|
int name = int.Parse(imageName);
|
|
int name1 = name * 2 - 1;
|
|
int name2 = name * 2;
|
|
deep1_text.text = name1.ToString() + "#深井泵";
|
|
deep2_text.text = name2.ToString() + "#深井泵";
|
|
//deep1_text.text = int.Parse(imageName) * 2 - 1;
|
|
//deep2_text.text = imageName * 2;
|
|
|
|
}
|
|
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (m_FollowObj != null)
|
|
{
|
|
Vector3 screenPos = Camera.main.WorldToScreenPoint(m_FollowObj.position);
|
|
if (screenPos.z > 0)
|
|
{
|
|
screenPos.z = 0;
|
|
transform.position = screenPos + m_Offset;
|
|
|
|
}
|
|
else
|
|
{
|
|
transform.position = new Vector3(8888, 8888, 8888);
|
|
}
|
|
//if (GameManager.Instance)
|
|
//{
|
|
|
|
|
|
// float distance = Vector3.Distance(m_FollowObj.transform.position, Camera.main.transform.position);
|
|
// if (distance > 15 && GameManager.Instance.isShowUI)//Ui显示隐藏
|
|
// {
|
|
// transform.localScale = Vector3.one * 2.1f;
|
|
// }
|
|
// else
|
|
// {
|
|
// transform.localScale = Vector3.zero;
|
|
// }
|
|
//}
|
|
|
|
}
|
|
}
|
|
}
|