加入很多新内容,这波一块交了
This commit is contained in:
@@ -139,19 +139,27 @@ public class chooseSkillPrefab : MonoBehaviour, IPointerEnterHandler, IPointerEx
|
||||
detailPinnedByButton = pinnedByButton;
|
||||
detailOpenedFrame = Time.frameCount;
|
||||
|
||||
Transform parent = transform.root != null ? transform.root : transform;
|
||||
Transform parent = ResolveDetailParent();
|
||||
spawnedDetail = Instantiate(sskilldetialPrefab, parent);
|
||||
spawnedDetail.transform.SetAsLastSibling();
|
||||
|
||||
RectTransform selfRect = transform as RectTransform;
|
||||
RectTransform detailRect = spawnedDetail.transform as RectTransform;
|
||||
RectTransform parentRect = parent as RectTransform;
|
||||
if (selfRect != null && detailRect != null && parentRect != null)
|
||||
{
|
||||
Canvas canvas = parent.GetComponentInParent<Canvas>();
|
||||
Camera eventCamera = null;
|
||||
if (canvas != null && canvas.renderMode != RenderMode.ScreenSpaceOverlay)
|
||||
{
|
||||
eventCamera = canvas.worldCamera;
|
||||
}
|
||||
|
||||
Vector3 worldPoint = selfRect.TransformPoint(new Vector3(selfRect.rect.xMax, selfRect.rect.center.y, 0f));
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(
|
||||
parentRect,
|
||||
RectTransformUtility.WorldToScreenPoint(null, worldPoint),
|
||||
null,
|
||||
RectTransformUtility.WorldToScreenPoint(eventCamera, worldPoint),
|
||||
eventCamera,
|
||||
out Vector2 localPoint);
|
||||
detailRect.anchoredPosition = localPoint + detailPrefabOffset;
|
||||
}
|
||||
@@ -163,6 +171,22 @@ public class chooseSkillPrefab : MonoBehaviour, IPointerEnterHandler, IPointerEx
|
||||
}
|
||||
}
|
||||
|
||||
private Transform ResolveDetailParent()
|
||||
{
|
||||
Canvas canvas = GetComponentInParent<Canvas>();
|
||||
if (canvas != null && canvas.rootCanvas != null)
|
||||
{
|
||||
return canvas.rootCanvas.transform;
|
||||
}
|
||||
|
||||
if (transform.root != null)
|
||||
{
|
||||
return transform.root;
|
||||
}
|
||||
|
||||
return transform;
|
||||
}
|
||||
|
||||
private bool IsPointerInside(Vector2 screenPoint)
|
||||
{
|
||||
if (IsScreenPointInside(transform as RectTransform, screenPoint))
|
||||
|
||||
Reference in New Issue
Block a user