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

This commit is contained in:
FloatGaming
2026-07-13 02:28:39 +08:00
parent 1e20d73e90
commit fd22501f71
958 changed files with 378289 additions and 41038 deletions
+1 -1
View File
@@ -1262,7 +1262,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 260}
m_AnchoredPosition: {x: 0, y: 160}
m_SizeDelta: {x: 300, y: 0}
m_Pivot: {x: 0.5, y: 1}
--- !u!222 &7576639242479402706
+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)
+2
View File
@@ -85,6 +85,8 @@ MonoBehaviour:
eqpmtDesPrefab: {fileID: 2338382027758302449, guid: 00982b98d18fbe94cb371f5451f6e244, type: 3}
popupParent: {fileID: 0}
popupHorizontalOffset: 120
popupBottomEdgePadding: 128
popupBottomAvoidanceOffset: 200
onItemClicked:
m_PersistentCalls:
m_Calls: []