using TMPro; using Unity.Mathematics; using UnityEngine; using UnityEngine.UI; public class RectangleMeasureGroup : MeasureGroup { private PolygonMeasureGroupInfoPopup polygonMeasureGroupInfoPopup; public override void AddPoint(Vector3 pos) { if(points.Count >= 3) return; points.Add(pos); switch (points.Count) { case 1: AddFirstPoint(pos); break; case 2: AddSecondPoint(pos); break; case 3: AddThirdPoint(pos); break; } } private void AddFirstPoint(Vector3 pos) { if (!polygonMeasureGroupInfoPopup) { polygonMeasureGroupInfoPopup = Instantiate(polygonInfoPopupPrefab).GetComponent(); polygonMeasureGroupInfoPopup.InitUI(infoPopupRoot); polygonMeasureGroupInfoPopup.transform.position = pos + new Vector3(20, 0, 20); } GameObject label = Instantiate(labelPrefab, pos, Quaternion.identity, labelRoot); labels.Add(label); } private void AddSecondPoint(Vector3 pos) { while (labels.Count < 4) { GameObject label = Instantiate(labelPrefab, pos, Quaternion.identity, labelRoot); labels.Add(label); } } private void AddThirdPoint(Vector3 pos) { deleteButton = Instantiate(deleteButtonPrefab, points[0], Quaternion.identity, infoPopupRoot); deleteButton.GetComponentInChildren