fix
- TowerSelectItem 显示问题 - CombatSelectForm 不同分辨率的适配
This commit is contained in:
@@ -33,7 +33,7 @@ namespace GeometryTD.UI
|
||||
return;
|
||||
}
|
||||
|
||||
_content.anchoredPosition = context.ContentPosition;
|
||||
_content.anchoredPosition = ResolveContentAnchoredPosition(context.ScreenPosition);
|
||||
|
||||
if (_buildArea != null)
|
||||
{
|
||||
@@ -107,5 +107,35 @@ namespace GeometryTD.UI
|
||||
Transform contentTransform = transform.Find("Content");
|
||||
_content = contentTransform as RectTransform;
|
||||
}
|
||||
|
||||
private Vector2 ResolveContentAnchoredPosition(Vector2 screenPosition)
|
||||
{
|
||||
if (_content == null)
|
||||
{
|
||||
return Vector2.zero;
|
||||
}
|
||||
|
||||
RectTransform parentRect = _content.parent as RectTransform;
|
||||
if (parentRect == null)
|
||||
{
|
||||
return screenPosition;
|
||||
}
|
||||
|
||||
Canvas canvas = _content.GetComponentInParent<Canvas>();
|
||||
Canvas rootCanvas = canvas != null ? canvas.rootCanvas : null;
|
||||
Camera uiCamera = null;
|
||||
if (rootCanvas != null && rootCanvas.renderMode != RenderMode.ScreenSpaceOverlay)
|
||||
{
|
||||
uiCamera = rootCanvas.worldCamera != null ? rootCanvas.worldCamera : Camera.main;
|
||||
}
|
||||
|
||||
if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(parentRect, screenPosition, uiCamera,
|
||||
out Vector2 localPoint))
|
||||
{
|
||||
return Vector2.zero;
|
||||
}
|
||||
|
||||
return localPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user