Hi! I am faced with the problem of positioning maps at different screen resolutions
1920x1080
[170721-1920x1080.png*|170721]
1280x720
[170722-1280x720.png*|170722]
As you can see, there is a different behavior of the location of the cards
There is a script that align cards
private void AlignCards()
{
StopAllCoroutines(); // Stop all animations to start new TODO: Stop only card aligning coroutines, not all
float cardWidth = cardSize.x;
float offsetX = cardSize.x * offsetMultiplier - (cardList.Count * offsetMultiplier * cardSize.x * 0.4f);
float totalCardWidth = cardWidth + offsetX;
float totalWidth = cardList.Count * totalCardWidth;
for (int i = 0; i < cardList.Count; i++)
{
GameObject card = cardList*;*
if (card == currentCardDrag) continue;
Vector3 cardPos = card.transform.position;
cardPos.x = totalWidth * .5f - totalCardWidth * (cardList.Count - i) + totalCardWidth * .5f + transform.position.x; // Calculate position based on card order in a hand
cardPos.y = transform.position.y;
this.SmoothMovement(card.transform, cardPos, duration);
}
}
Card Size is
RectTransform cardRect = cardPrefab.GetComponent();
cardSize = new Vector2(cardRect.rect.width, cardRect.rect.height);
*
*