알람 개발 중
This commit is contained in:
@@ -19,6 +19,14 @@ namespace UVC.Factory.Alarm
|
||||
[SerializeField] private GameObject expandedView;
|
||||
[Tooltip("개별 알람 아이콘 프리팹입니다. 이 프리팹은 개별 알람 정보를 표시하는 UI 요소를 포함해야 합니다.")]
|
||||
[SerializeField] private GameObject alarmSingleIconPrefab; // 개별 알람 아이콘
|
||||
[Tooltip("아이콘이 중심에서의 Y Offset")]
|
||||
[SerializeField] private float iconYOffset = 10f;
|
||||
[Tooltip("확장 시 아이콘 간의 간격입니다.")]
|
||||
[SerializeField] private float iconSpacing = 10f;
|
||||
[Tooltip("확장 시 아이콘들의 중심 X 오프셋입니다.")]
|
||||
[SerializeField] private float expandOffsetX = 0f;
|
||||
[Tooltip("확장 시 아이콘들의 중심 Y 오프셋입니다.")]
|
||||
[SerializeField] private float expandOffsetY = 0f;
|
||||
|
||||
private Transform targetObject;
|
||||
private List<DataObject> alarms = new List<DataObject>();
|
||||
@@ -28,7 +36,6 @@ namespace UVC.Factory.Alarm
|
||||
private RectTransform rectTransform;
|
||||
private Canvas mainCanvas;
|
||||
|
||||
private float uiSpacing = 20f; // 간격
|
||||
private Tweener uiSpacingTweener;
|
||||
|
||||
private bool isZoomIn = false; // 줌 인 상태를 추적하기 위한 변수
|
||||
@@ -79,13 +86,13 @@ namespace UVC.Factory.Alarm
|
||||
{
|
||||
Vector2 localPoint;
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(mainCanvas.transform as RectTransform, screenPoint, mainCanvas.worldCamera, out localPoint);
|
||||
localPoint.y += uiSpacing;
|
||||
localPoint.y += iconYOffset;
|
||||
rectTransform.localPosition = localPoint;
|
||||
}
|
||||
// Canvas Render Mode가 Screen Space - Overlay일 경우
|
||||
else
|
||||
{
|
||||
screenPoint.y += uiSpacing;
|
||||
screenPoint.y += iconYOffset;
|
||||
rectTransform.position = screenPoint;
|
||||
}
|
||||
}
|
||||
@@ -202,6 +209,7 @@ namespace UVC.Factory.Alarm
|
||||
clusterView.SetActive(false);
|
||||
expandedView.SetActive(true);
|
||||
singleAlarmIcon1.gameObject.SetActive(false);
|
||||
alarmCountText.gameObject.SetActive(false);
|
||||
|
||||
// 기존 아이콘들 삭제
|
||||
foreach (Transform child in expandedView.transform)
|
||||
@@ -209,13 +217,29 @@ namespace UVC.Factory.Alarm
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
|
||||
// 원형으로 아이콘 배치
|
||||
float radius = (alarms.Count - 1) * 20.0f; // Canvas 좌표계에 맞는 반지름 값
|
||||
|
||||
// alarmSingleIconPrefab의 RectTransform을 가져와 아이콘의 너비를 계산합니다.
|
||||
RectTransform iconRect = alarmSingleIconPrefab.GetComponent<RectTransform>();
|
||||
if (iconRect == null)
|
||||
{
|
||||
Debug.LogError("alarmSingleIconPrefab에 RectTransform 컴포넌트가 없습니다.");
|
||||
return;
|
||||
}
|
||||
float iconWidth = iconRect.rect.width;
|
||||
|
||||
// 아이콘의 개수와 너비, 간격을 고려하여 필요한 원주를 계산합니다.
|
||||
float circumference = (iconWidth + iconSpacing) * alarms.Count;
|
||||
|
||||
// 원주를 이용하여 반지름(radius)을 계산합니다.
|
||||
float radius = circumference / (2f * Mathf.PI);
|
||||
|
||||
// 중심 오프셋을 적용할 Vector3를 생성합니다.
|
||||
Vector3 centerOffset = new Vector3(expandOffsetX, expandOffsetY, 0);
|
||||
|
||||
for (int i = 0; i < alarms.Count; i++)
|
||||
{
|
||||
float angle = i * Mathf.PI * 2f / alarms.Count;
|
||||
Vector3 pos = new Vector3(Mathf.Cos(angle), Mathf.Sin(angle), 0) * radius;
|
||||
// 오프셋을 적용하여 아이콘의 위치를 계산합니다.
|
||||
Vector3 pos = centerOffset + new Vector3(Mathf.Cos(angle), Mathf.Sin(angle), 0) * radius;
|
||||
|
||||
GameObject iconObj = Instantiate(alarmSingleIconPrefab, expandedView.transform);
|
||||
iconObj.transform.localPosition = pos;
|
||||
@@ -245,9 +269,9 @@ namespace UVC.Factory.Alarm
|
||||
{
|
||||
uiSpacingTweener.Kill();
|
||||
}
|
||||
uiSpacingTweener = DOVirtual.Float(uiSpacing, targetSpacing, duration, (value) =>
|
||||
uiSpacingTweener = DOVirtual.Float(iconYOffset, targetSpacing, duration, (value) =>
|
||||
{
|
||||
uiSpacing = value;
|
||||
iconYOffset = value;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user