57 lines
1.5 KiB
C#
57 lines
1.5 KiB
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
using TMPro;
|
||
|
|
using WI;
|
||
|
|
using UnityEngine.EventSystems;
|
||
|
|
|
||
|
|
public class UI_GraphChartData : UIBase, ISingle
|
||
|
|
{
|
||
|
|
public TextMeshProUGUI DataName;
|
||
|
|
public TextMeshProUGUI DataValue;
|
||
|
|
public TextMeshProUGUI DateTime;
|
||
|
|
|
||
|
|
public Vector3 offset;
|
||
|
|
private OrbitalController orbitalController;
|
||
|
|
|
||
|
|
public override void AfterAwake()
|
||
|
|
{
|
||
|
|
orbitalController = FindSingle<OrbitalController>();
|
||
|
|
SetActive(false);
|
||
|
|
}
|
||
|
|
public void SetData(string dataName, float dataValue, string dateTime, Vector3 pos)
|
||
|
|
{
|
||
|
|
ShowUINextToClickedUI();
|
||
|
|
|
||
|
|
DataName.SetText(dataName);
|
||
|
|
DateTime.SetText(dateTime);
|
||
|
|
|
||
|
|
float truncatedFloat = Mathf.Floor(dataValue * 10f) / 10f;
|
||
|
|
DataValue.SetText(truncatedFloat.ToString());
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
void ShowUINextToClickedUI()
|
||
|
|
{
|
||
|
|
RectTransform parentRectTransform = rectTransform.parent.GetComponent<RectTransform>();
|
||
|
|
|
||
|
|
Vector2 localPoint;
|
||
|
|
RectTransformUtility.ScreenPointToLocalPointInRectangle(parentRectTransform, Input.mousePosition, null, out localPoint);
|
||
|
|
|
||
|
|
rectTransform.localPosition = new Vector2(localPoint.x + offset.x, localPoint.y + offset.y);
|
||
|
|
|
||
|
|
gameObject.SetActive(true);
|
||
|
|
}
|
||
|
|
|
||
|
|
void Update()
|
||
|
|
{
|
||
|
|
if (Input.GetMouseButtonDown(0))
|
||
|
|
{
|
||
|
|
if (EventSystem.current.currentSelectedGameObject != null)
|
||
|
|
return;
|
||
|
|
|
||
|
|
SetActive(false);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|