26.04.03 가상공장 화면 디자인 반영 • 좌측 도구 창, 상단 UI, 하단 UI • 생산 현황판, 알림 현황판 • 설비 라벨, 요약 팝업, 대시보드, 데이터 보드 • 설정창, 미니맵, AI 시뮬레이션 결과창, 나가기 팝업 가상 공장 화면 디자인 변경에 따른 기능 추가 • 미니맵 드래그 및 위치 조정 기능 추가 • UI 상호 작용(호버링, 선택, 위치 이동, 재설정) • UI 기능 추가(상태 표시, 색상)
176 lines
6.0 KiB
C#
176 lines
6.0 KiB
C#
using AZTECHWB.Extensions;
|
|
using AZTECHWB.Management;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
namespace AZTECHWB
|
|
{
|
|
public class MachineStatusItem : MonoBehaviour, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler
|
|
{
|
|
public RectTransform rectTransform;
|
|
public CompleteInfo data;
|
|
private RectTransform Default_KPI;
|
|
private RectTransform Expand_KPI;
|
|
|
|
private Slider Slider_eorate;
|
|
|
|
private TMP_Text DefaultMachineName;
|
|
private TMP_Text ExpandMachineName;
|
|
private Image Default_Status;
|
|
private Image Expand_Status;
|
|
|
|
private Image Default_Alarm;
|
|
private Image Expand_Alarm;
|
|
|
|
private TMP_Text eorate;
|
|
private TMP_Text workcd;
|
|
private TMP_Text goodqtyrate;
|
|
private TMP_Text workdt;
|
|
private TMP_Text wordno;
|
|
|
|
public bool isInteractable;
|
|
private bool isExpand;
|
|
|
|
[HideInInspector] public Transform targetTransform;
|
|
[HideInInspector] public Vector2 screenPosition;
|
|
[HideInInspector] public float distanceToCamera;
|
|
|
|
public Action<MachineStatusItem> onClickIcon;
|
|
|
|
public void Init(Machine machine)
|
|
{
|
|
isInteractable = true;
|
|
gameObject.name = machine.machineName;
|
|
targetTransform = machine.transform;
|
|
|
|
rectTransform = GetComponent<RectTransform>();
|
|
transform.TryGetComponentInChildren(nameof(Default_KPI), out Default_KPI);
|
|
transform.TryGetComponentInChildren(nameof(Expand_KPI), out Expand_KPI);
|
|
|
|
transform.TryGetComponentInChildren(nameof(DefaultMachineName), out DefaultMachineName);
|
|
transform.TryGetComponentInChildren(nameof(ExpandMachineName), out ExpandMachineName);
|
|
|
|
transform.TryGetComponentInChildren(nameof(Default_Status), out Default_Status);
|
|
transform.TryGetComponentInChildren(nameof(Expand_Status), out Expand_Status);
|
|
transform.TryGetComponentInChildren(nameof(Default_Alarm), out Default_Alarm);
|
|
transform.TryGetComponentInChildren(nameof(Expand_Alarm), out Expand_Alarm);
|
|
|
|
transform.TryGetComponentInChildren(nameof(Slider_eorate), out Slider_eorate);
|
|
|
|
transform.TryGetComponentInChildren(nameof(eorate), out eorate);
|
|
transform.TryGetComponentInChildren(nameof(workcd), out workcd);
|
|
transform.TryGetComponentInChildren(nameof(goodqtyrate), out goodqtyrate);
|
|
transform.TryGetComponentInChildren(nameof(workdt), out workdt);
|
|
transform.TryGetComponentInChildren(nameof(wordno), out wordno);
|
|
}
|
|
|
|
public void SetData(CompleteInfo data)
|
|
{
|
|
this.data = data;
|
|
|
|
SetSliderValue(Slider_eorate, 100f, DataExtensions.PercentCalculate(data.eorate));
|
|
|
|
eorate.SetText($"{DataExtensions.PercentCalculate(data.eorate)}%");
|
|
workcd.SetText(DataExtensions.SetStringTextData(data.workcd));
|
|
goodqtyrate.SetText($"{DataExtensions.PercentCalculate(data.goodqtyrate)}%");
|
|
workdt.SetText(DataExtensions.CorrectionMonthDay(data.workdt, "yyyy.MM.dd"));
|
|
wordno.SetText(DataExtensions.SetStringTextData(data.wordno));
|
|
|
|
DefaultMachineName.SetText(DataExtensions.SetStringTextData(data.worknm, gameObject.name));
|
|
ExpandMachineName.SetText(DataExtensions.SetStringTextData(data.worknm, gameObject.name));
|
|
|
|
Default_Status.color = SetStatusColor(data.statusnm);
|
|
Expand_Status.color = SetStatusColor(data.statusnm);
|
|
|
|
DefaultMachineName.color = SetStatusColor(data.statusnm) == Color.gray ? Color.gray : DefaultMachineName.color;
|
|
ExpandMachineName.color = SetStatusColor(data.statusnm) == Color.gray ? Color.gray : ExpandMachineName.color;
|
|
}
|
|
private void SetSliderValue(Slider slider, float max, float value)
|
|
{
|
|
slider.minValue = 0f;
|
|
slider.maxValue = max;
|
|
slider.value = value;
|
|
}
|
|
|
|
private Color SetStatusColor(string value)
|
|
{
|
|
var newColor = Color.white;
|
|
|
|
switch (value)
|
|
{
|
|
case "가동중":
|
|
newColor = Color.green;
|
|
break;
|
|
case "비가동":
|
|
newColor = Color.gray;
|
|
break;
|
|
default:
|
|
newColor = Color.red;
|
|
break;
|
|
}
|
|
return newColor;
|
|
}
|
|
|
|
public void Active()
|
|
{
|
|
gameObject.SetActive(true);
|
|
}
|
|
public void Deactive()
|
|
{
|
|
isExpand = false;
|
|
Default_KPI.gameObject.SetActive(true);
|
|
Expand_KPI.gameObject.SetActive(false);
|
|
gameObject.SetActive(false);
|
|
}
|
|
|
|
public void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
if (!isInteractable)
|
|
return;
|
|
|
|
onClickIcon?.Invoke(this);
|
|
}
|
|
|
|
public void OnPointerEnter(PointerEventData eventData)
|
|
{
|
|
if (!isInteractable)
|
|
return;
|
|
|
|
if (!isExpand)
|
|
{
|
|
if (Expand_KPI == null && Default_KPI == null)
|
|
return;
|
|
|
|
Expand_KPI.gameObject.SetActive(true);
|
|
Default_KPI.gameObject.SetActive(false);
|
|
|
|
isExpand = true;
|
|
transform.SetAsLastSibling();
|
|
}
|
|
}
|
|
|
|
public void OnPointerExit(PointerEventData eventData)
|
|
{
|
|
if (isExpand)
|
|
{
|
|
Default_KPI.gameObject.SetActive(true);
|
|
Expand_KPI.gameObject.SetActive(false);
|
|
isExpand = false;
|
|
}
|
|
}
|
|
|
|
public Vector2 GetSize()
|
|
{
|
|
Vector2 baseSize = rectTransform.sizeDelta;
|
|
float scale = transform.localScale.x; // UpdateScales에서 적용한 스케일
|
|
return baseSize * scale;
|
|
}
|
|
}
|
|
}
|
|
|