ui基本完毕,修了一大把的bug

This commit is contained in:
2026-07-13 02:28:39 +08:00
parent 1e20d73e90
commit fd22501f71
958 changed files with 378289 additions and 41038 deletions
+45
View File
@@ -25,6 +25,8 @@ public class equipItemPrefab : MonoBehaviour, IBeginDragHandler, IDragHandler, I
public GameObject eqpmtDesPrefab;
public Transform popupParent;
public float popupHorizontalOffset = 40f;
public float popupBottomEdgePadding = 32f;
public float popupBottomAvoidanceOffset = 24f;
[Header("events")]
public UnityEvent<equipmentSO> onItemClicked;
@@ -186,6 +188,49 @@ public class equipItemPrefab : MonoBehaviour, IBeginDragHandler, IDragHandler, I
float halfPopupWidth = popupRect.rect.width * 0.5f;
float xOffset = halfItemWidth + halfPopupWidth + popupHorizontalOffset;
popupRect.anchoredPosition = localPoint + new Vector2(placeLeft ? -xOffset : xOffset, 0f);
AdjustPopupAwayFromBottomEdge(popupRect, parentRect, itemRect, localUiCamera);
}
private void AdjustPopupAwayFromBottomEdge(RectTransform popupRect, RectTransform parentRect, RectTransform itemRect, Camera localUiCamera)
{
if (popupRect == null || parentRect == null || itemRect == null)
{
return;
}
Vector3[] itemCorners = new Vector3[4];
itemRect.GetWorldCorners(itemCorners);
float bottom = RectTransformUtility.WorldToScreenPoint(localUiCamera, itemCorners[0]).y;
float minBottom = popupBottomEdgePadding;
float shiftScreenY = 0f;
if (bottom < minBottom)
{
shiftScreenY = (minBottom - bottom) + Mathf.Max(0f, popupBottomAvoidanceOffset);
}
if (Mathf.Approximately(shiftScreenY, 0f))
{
return;
}
Vector2 currentScreenPoint = RectTransformUtility.WorldToScreenPoint(localUiCamera, popupRect.position);
Vector2 adjustedScreenPoint = currentScreenPoint + new Vector2(0f, shiftScreenY);
if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(parentRect, currentScreenPoint, localUiCamera, out Vector2 currentLocalPoint))
{
return;
}
if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(parentRect, adjustedScreenPoint, localUiCamera, out Vector2 adjustedLocalPoint))
{
return;
}
Vector2 localDelta = adjustedLocalPoint - currentLocalPoint;
popupRect.anchoredPosition += localDelta;
}
public void OnBeginDrag(PointerEventData eventData)