26.04.03 가상공장 화면 디자인 반영 • 좌측 도구 창, 상단 UI, 하단 UI • 생산 현황판, 알림 현황판 • 설비 라벨, 요약 팝업, 대시보드, 데이터 보드 • 설정창, 미니맵, AI 시뮬레이션 결과창, 나가기 팝업 가상 공장 화면 디자인 변경에 따른 기능 추가 • 미니맵 드래그 및 위치 조정 기능 추가 • UI 상호 작용(호버링, 선택, 위치 이동, 재설정) • UI 기능 추가(상태 표시, 색상)
93 lines
3.1 KiB
C#
93 lines
3.1 KiB
C#
using AZTECHWB.Core;
|
|
using AZTECHWB.Management;
|
|
using Cysharp.Threading.Tasks;
|
|
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace AZTECHWB.UI
|
|
{
|
|
public class MiniMap : UIPanel
|
|
{
|
|
private RectTransform rectTransform;
|
|
GameObject target;
|
|
|
|
private Image MiniMapScreen;
|
|
private RectTransform Image_MiniMapIcon;
|
|
private Button Button_Close;
|
|
|
|
public Vector2 worldPos;
|
|
|
|
public Vector2 worldMin;
|
|
public Vector2 worldMax;
|
|
public float offset;
|
|
|
|
public Action onClickCloseButton;
|
|
|
|
//[SerializeField] Sprite[] miniMapImages;
|
|
|
|
public override async UniTask Init()
|
|
{
|
|
rectTransform = transform.GetComponent<RectTransform>();
|
|
target = AZTECHAppMain.Instance.cameraController.cameraPivot.gameObject;
|
|
|
|
MiniMapScreen = GetElement<Image>(nameof(MiniMapScreen));
|
|
Image_MiniMapIcon = GetElement<RectTransform>(nameof(Image_MiniMapIcon));
|
|
Button_Close = GetElement<Button>(nameof(Button_Close));
|
|
|
|
Button_Close.onClick.AddListener(Close);
|
|
|
|
await UniTask.CompletedTask;
|
|
}
|
|
|
|
public override void Close()
|
|
{
|
|
var topMenuPanel = AZTECHSceneMain.Instance.GetManager<AZTECHUIManager>().GetCanvas<StaticCanvas>().GetPanel<LeftSidePanel>();
|
|
topMenuPanel.SetToggleButton("button_minimap_screen", false);
|
|
gameObject.SetActive(false);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
//UpdateMiniMapBackground();
|
|
UpdateMiniMapIcon();
|
|
}
|
|
// private void UpdateMiniMapBackground()
|
|
// {
|
|
// var sprite = building.isOnlyMachineFloorsEnabled ? miniMapImages[1] : miniMapImages[0];
|
|
// MiniMapScreen.sprite = sprite;
|
|
// }
|
|
|
|
void UpdateMiniMapIcon()
|
|
{
|
|
Vector2 worldPos = new Vector2(target.transform.position.x, target.transform.position.z);
|
|
Vector2 normalizedPos = (worldPos - worldMin) / (worldMax - worldMin);
|
|
|
|
RectTransform miniMapRect = MiniMapScreen.GetComponent<RectTransform>();
|
|
Vector2 miniMapSize = miniMapRect.rect.size;
|
|
Vector2 iconPos = new Vector2(
|
|
-((normalizedPos.x * miniMapSize.x) - (miniMapSize.x * 0.5f)),
|
|
-((normalizedPos.y * miniMapSize.y) - (miniMapSize.y * 0.5f))
|
|
);
|
|
|
|
Image_MiniMapIcon.anchoredPosition = iconPos;
|
|
}
|
|
public void ShowPopupNextToButton(RectTransform buttonRect, float offset)
|
|
{
|
|
Canvas.ForceUpdateCanvases();
|
|
|
|
var canvas = rectTransform.GetComponentInParent<Canvas>();
|
|
float scaledOffset = offset / canvas.scaleFactor;
|
|
|
|
Vector3 pos = buttonRect.position;
|
|
|
|
pos.x += buttonRect.rect.width * (1 - buttonRect.pivot.x) + scaledOffset;
|
|
pos.y += buttonRect.rect.height * (1 - buttonRect.pivot.y);
|
|
|
|
pos.x += rectTransform.rect.width * rectTransform.pivot.x;
|
|
pos.y -= rectTransform.rect.height * (1 - rectTransform.pivot.y);
|
|
|
|
rectTransform.position = pos;
|
|
}
|
|
}
|
|
} |