Nicole Erasga
Nicole Erasga

Reputation: 31

WorldToScreenPoint but still different positions

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;
}

heres the output enter image description here

Upvotes: 0

Views: 1595

Answers (2)

Davit Sedrakyan
Davit Sedrakyan

Reputation: 317

as I Understood you need to use ScreenToWorldPoint!

https://docs.unity3d.com/ScriptReference/Camera.ScreenToWorldPoint.html

check this

Upvotes: 0

shingo
shingo

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

Related Questions