Reputation: 31
So I have started using WorldToScreenPoint but the thing is the object is not the same on different screen sizes :(
heres my codes
public virtual void Move()
{
Vector2 buttonFirst = thisCam.WorldToScreenPoint(gameButtons[0].transform.position);
buttonFirst.x = 316.5f; //242
buttonFirst.y = 111f;
gameButtons[0].transform.position = buttonFirst;
}
Upvotes: 0
Views: 1595
Reputation: 317
as I Understood you need to use ScreenToWorldPoint!
https://docs.unity3d.com/ScriptReference/Camera.ScreenToWorldPoint.html
check this
Upvotes: 0
Reputation: 27442
the object is not the same on different screen sizes
Of course, different size so different position.
If you need the return position to be invariable, use WorldToViewportPoint, it always returns a value between (0,0) to (1,1).
Upvotes: 3